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(1145,1057,1218,1146,1150,983,1013,960,925,1087,1063,1049,1153,972,1111,985,1005,820,976,982,960,842,1008,1086,1207,958,1040,800,886,906,892,908,1025,1108,1097,1074,981,920,1065,994,1021,864,864,837,920,1085,1048,1112,1080,1140,1159,1044,871,807,1110,1078,1079,1247,1136,1066,1073,976,1073,1144,1023,694,1052,1124,1104,1183,1320,1227) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/17y9d1425587345.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/2uja21425587345.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/3a5x21425587345.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.439494569 0.181124743 -0.038165255 -0.086815356 [6] -0.233077653 -0.145775491 -0.077208454 0.006848104 0.144325912 [11] 0.259036864 0.162403783 0.361298429 0.171143720 0.109967659 [16] -0.077906340 -0.076619487 -0.227927034 -0.285005665 -0.163241506 [21] -0.007432976 0.125091476 0.242897470 0.173473656 0.175787419 [26] -0.005923361 -0.080449253 -0.293314661 -0.256418216 -0.263816746 [31] -0.187710079 -0.058328457 -0.065924000 -0.022127338 0.048413342 [36] 0.093967718 0.096860718 -0.008320406 -0.008483362 -0.189528116 [41] -0.212439934 -0.311397833 -0.227121917 -0.106057178 0.038668590 [46] 0.115485473 0.094037106 0.100492991 0.076157056 > (mypacf <- c(rpacf$acf)) [1] 0.439494569 -0.014910845 -0.139341976 -0.021729177 -0.202261782 [6] 0.039542809 0.009289792 0.005630428 0.159213555 0.126833369 [11] -0.052666286 0.398224361 -0.142960568 0.115708727 -0.024821728 [16] -0.063719796 -0.060587651 -0.243327422 0.028397509 0.039933874 [21] -0.027041998 0.084800948 -0.048751112 -0.013392863 -0.018733696 [26] -0.139744263 -0.077796510 -0.048995233 -0.129083075 0.057473580 [31] -0.019523371 -0.247552189 0.024138189 -0.092928963 0.049385297 [36] 0.062473318 -0.083887695 0.190663535 -0.051434547 -0.064250989 [41] -0.029775170 -0.072901903 -0.019456536 0.113043659 -0.136156555 [46] 0.017573707 0.023969661 -0.047570534 > 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/4py1v1425587345.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/5kmxj1425587345.tab") > > try(system("convert tmp/17y9d1425587345.ps tmp/17y9d1425587345.png",intern=TRUE)) character(0) > try(system("convert tmp/2uja21425587345.ps tmp/2uja21425587345.png",intern=TRUE)) character(0) > try(system("convert tmp/3a5x21425587345.ps tmp/3a5x21425587345.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.242 0.229 1.475