R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(92.86,94.06,95.51,96.05,96.71,97.91,97.74,97.64,98.55,98.46,99.19,99.18,99.95,100.66,101.12,101.14,100.73,99.92,100.06,100.64,100.89,100.87,100.72,100.72,100.98,100.15,100.13,100.39,99.87,99.93,99.96,99.61,99.57,99.71,99.78,99.92,100.3,100.83,100.84,97.87,97.99,98.03,97.58,97.45,97.47,98.31,98.29,98.13,98.44,98.05,98.32,97.55,97.74,98.01,97.93,99.23,101.03,100.81,100.57,100.1) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '48' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_autocorrelation.wasp/ > #Source of accompanying publication: > # > if (par1 == 'Default') { + par1 = 10*log10(length(x)) + } else { + par1 <- as.numeric(par1) + } > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > if (par6 == 'White Noise') par6 <- 'white' else par6 <- 'ma' > par7 <- as.numeric(par7) > if (par8 != '') par8 <- as.numeric(par8) > x <- na.omit(x) > ox <- x > if (par8 == '') { + if (par2 == 0) { + x <- log(x) + } else { + x <- (x ^ par2 - 1) / par2 + } + } else { + x <- log(x,base=par8) + } > if (par3 > 0) x <- diff(x,lag=1,difference=par3) > if (par4 > 0) x <- diff(x,lag=par5,difference=par4) > postscript(file="/var/wessaorg/rcomp/tmp/18mrq1457985574.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > plot(ox,type='l',main='Original Time Series',xlab='time',ylab='value') > if (par8=='') { + mytitle <- paste('Working Time Series (lambda=',par2,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(lambda=',par2,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } else { + mytitle <- paste('Working Time Series (base=',par8,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(base=',par8,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } > plot(x,type='l', main=mytitle,xlab='time',ylab='value') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2sm051457985574.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > racf <- acf(x, par1, main='Autocorrelation', xlab='time lag', ylab='ACF', ci.type=par6, ci=par7, sub=mysub) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3bra31457985574.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > rpacf <- pacf(x,par1,main='Partial Autocorrelation',xlab='lags',ylab='PACF',sub=mysub) > dev.off() null device 1 > (myacf <- c(racf$acf)) [1] 1.000000000 0.177166357 -0.011493086 0.090330404 -0.016693284 [6] -0.005537696 -0.078985988 0.069161200 0.200870593 0.027170241 [11] 0.153800099 0.162710265 0.033917352 -0.079096937 0.010582949 [16] -0.063309045 -0.130411444 -0.158964799 0.080370026 0.068997838 [21] -0.077186802 -0.032713197 0.088271849 -0.013130564 -0.056373127 [26] -0.049961363 -0.044302028 -0.133576911 -0.055232897 -0.088386556 [31] -0.071131099 -0.132405042 0.063594815 0.049471693 -0.105822978 [36] -0.016408955 -0.014806588 -0.145988955 -0.205132547 -0.160933672 [41] -0.021768175 -0.037517222 0.067862382 0.087789421 0.027645589 [46] -0.011464865 -0.042669837 -0.029955745 0.019359022 > (mypacf <- c(rpacf$acf)) [1] 0.177166357 -0.044270564 0.103753561 -0.055349624 0.015620924 [6] -0.097467464 0.116543244 0.165004813 -0.017081089 0.156969839 [11] 0.082957237 0.010571490 -0.105100830 0.068587914 -0.125932520 [16] -0.100987499 -0.161724956 0.091929023 -0.032905246 -0.075092014 [21] -0.049370353 0.078188263 0.012114938 0.037745254 0.020808802 [26] -0.039986670 -0.060445867 0.025191398 -0.132467841 -0.088680179 [31] -0.118815019 0.095270461 -0.053928200 -0.072977938 0.078920768 [36] -0.015908301 -0.110971983 -0.124072867 0.001706592 -0.052102993 [41] 0.016908619 0.103525732 0.021995516 -0.039751095 0.069531498 [46] -0.038890019 -0.013594509 0.129691802 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','ACF(k)','click here for more information about the Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 2:(par1+1)) { + a<-table.row.start(a) + a<-table.element(a,i-1,header=TRUE) + a<-table.element(a,round(myacf[i],6)) + mytstat <- myacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/46wcz1457985574.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Partial Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','PACF(k)','click here for more information about the Partial Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:par1) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,round(mypacf[i],6)) + mytstat <- mypacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5fs211457985574.tab") > > try(system("convert tmp/18mrq1457985574.ps tmp/18mrq1457985574.png",intern=TRUE)) character(0) > try(system("convert tmp/2sm051457985574.ps tmp/2sm051457985574.png",intern=TRUE)) character(0) > try(system("convert tmp/3bra31457985574.ps tmp/3bra31457985574.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.292 0.196 1.496