R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(250.8,247.6,237.8,226.4,217.2,211.4,207.6,204.3,197.5,193.6,192.3,192,196.1,191.9,185.6,179.4,173.9,169.2,166.8,165.2,161.4,160.8,163.7,170.8,182.7,190.9,197.8,205.1,210.7,220.2,229.7,237.1,241.6,250.4,258.6,269.9,283.2,289.6,281.8,274.7,267.6,261.4,260.5,260.7,254.2,250.5,253.4,263.7,276.2,273.8,265.9,258.4,253.5,250.7,252.8,255.3,251.2,252.5,257.8,269.9,291.6,298.9,295.6,292.1,290.9,290.6,298,304,304.3,309.8,322.3,340.2,369.3,376.7,379.7,379.5,377.8,381.6,394.6,399.3,400.4,408.2,419.1,437.7) > 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.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) 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) > 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/1awke1413483857.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/26hn81413483857.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/3klzm1413483857.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.696882685 0.347940655 0.135174894 0.076611875 [6] 0.179429151 0.224943129 0.069072804 -0.080400763 -0.068008466 [11] 0.081607366 0.363988640 0.451632403 0.222352622 -0.053390821 [16] -0.226632689 -0.271148650 -0.162440856 -0.114001429 -0.217673895 [21] -0.326062575 -0.295919893 -0.151397203 0.088505110 0.193331484 [26] 0.055635651 -0.124018453 -0.223702797 -0.223903936 -0.130574711 [31] -0.055891576 -0.095483397 -0.157499805 -0.102460167 0.044518122 [36] 0.274641750 0.350596873 0.235270912 0.097790422 0.021399599 [41] 0.008858718 0.067020273 0.092802138 0.046965383 -0.010325768 [46] 0.022730545 0.110292127 0.202857542 0.242922694 > (mypacf <- c(rpacf$acf)) [1] 0.6968826846 -0.2677235542 0.0300678608 0.0786983954 0.2258300183 [6] -0.0646321513 -0.2630071407 0.0299488476 0.2017116034 0.1493530958 [11] 0.3165557952 -0.0815018584 -0.3160573980 -0.1632523093 -0.1182765648 [16] -0.1876579039 0.0103057679 0.0736576090 0.0248081543 -0.0936908921 [21] 0.0427269610 -0.1075804276 0.0314304951 0.0914555200 -0.0001676624 [26] 0.0170375874 0.0765229918 -0.0699657336 -0.1179536118 0.0631293364 [31] 0.1159215170 -0.0643255727 0.1369934426 0.0754748679 0.0960374201 [36] -0.1380690436 -0.0152126331 0.0183933962 0.0626250843 0.0054229477 [41] -0.0011704596 -0.0530249221 0.1281051702 -0.1196478439 -0.0036983077 [46] -0.1061787122 -0.0488461529 0.0895065824 > 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/4ejme1413483857.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/5jfwj1413483857.tab") > > try(system("convert tmp/1awke1413483857.ps tmp/1awke1413483857.png",intern=TRUE)) character(0) > try(system("convert tmp/26hn81413483857.ps tmp/26hn81413483857.png",intern=TRUE)) character(0) > try(system("convert tmp/3klzm1413483857.ps tmp/3klzm1413483857.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.152 0.248 1.404