R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(110.12,112.28,113.77,114.38,119.06,119.94,120.98,122.33,121.7,123.73,121.73,119.75,117.4,120.99,125.18,126.41,129.38,131.93,129.34,128.58,125.37,123.25,122.78,120.37,116.83,116.39,120.69,123.51,127.43,125.99,120.62,113.71,110.79,108.15,111.22,112.65,112.47,117.48,122.46,123.46,122.33,129.2,129.22,131.17,120.22,120.38,115.32,112.25,109.83,107.05,112.87,113.68,115.08,120.61,119.14,118.63,115.78,117.26,117.61,113.92,113.65,115.89,116.55,117.78,117.36,121.09,124.26,121.88,119.52,122.49,120.86,120.31) > 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/1s6cc1384348403.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/2x6jm1384348403.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/3de071384348403.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.0000000000 0.8275071904 0.5973317971 0.3275173335 0.0756780454 [6] -0.1251417482 -0.2588622715 -0.2646485066 -0.1968093245 -0.1108221016 [11] 0.0009317328 0.1060584387 0.1697579099 0.1265980692 0.0216102893 [16] -0.0753812200 -0.2033080970 -0.3087239099 -0.3186801612 -0.2618913123 [21] -0.1727560383 -0.0737066954 0.0377156886 0.1582904013 0.2347663563 [26] 0.2027195259 0.1310234727 0.0542220203 -0.0069197444 -0.0748463202 [31] -0.1143683894 -0.1177063705 -0.1125650982 -0.1049735598 -0.0866659991 [36] -0.0716236381 -0.0524973427 -0.0758922882 -0.1246309403 -0.1635978876 [41] -0.2103689303 -0.2383989407 -0.2255616674 -0.1671607983 -0.0748263788 [46] -0.0278367124 0.0463643596 0.0959819752 0.1245817124 > (mypacf <- c(rpacf$acf)) [1] 0.827507190 -0.277371570 -0.255536262 -0.115853480 -0.054460908 [6] -0.034319510 0.195357472 0.053848300 -0.086239450 0.071305154 [11] 0.054503294 -0.046392417 -0.225402624 -0.096233739 0.077469181 [16] -0.158727990 -0.052775144 0.216187356 -0.023146174 -0.139453682 [21] 0.069031005 0.063668132 0.022518263 0.062223330 -0.185209994 [26] -0.047884857 0.103216639 0.162520271 -0.083747605 -0.165354452 [31] -0.052937839 0.012381085 -0.081622443 -0.017591805 -0.042035614 [36] -0.039330879 -0.069418461 -0.081065784 -0.048605980 -0.034982543 [41] 0.005416851 -0.034995991 -0.024128658 0.148061273 -0.121413597 [46] 0.044533788 -0.084884827 -0.049238889 > 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/4a2so1384348403.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/52wa31384348403.tab") > > try(system("convert tmp/1s6cc1384348403.ps tmp/1s6cc1384348403.png",intern=TRUE)) character(0) > try(system("convert tmp/2x6jm1384348403.ps tmp/2x6jm1384348403.png",intern=TRUE)) character(0) > try(system("convert tmp/3de071384348403.ps tmp/3de071384348403.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.765 0.360 2.104