R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 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(29358,28673,30383,30988,32565,32510,31584,32729,34977,36710,39457,39217,40435,41373,43221,43271,43605,42254,41702,41002,39804,40256,40740,42362,41126,40225,41216,39148,41591,39506,35261,34148,33947,32819,32700,32242,32810,33865,32226,31077,31293,30236,30160,32436,30695,27525,26434,25739,25204,24977,24320,22680,22052,21467,21383,21777,21928,21814,22937,23595,20830) > 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/12p8i1395088388.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/2eq5y1395088388.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/3nuez1395088388.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.1926036420 0.0416401127 0.1573612147 0.0159108926 [6] 0.1585928289 0.2332642018 0.0112851957 -0.0041935363 0.0690382764 [11] -0.0173579712 0.0400835901 0.1065343797 -0.0384330073 0.1361432799 [16] 0.1939926318 -0.0189528287 -0.2216984449 0.0224225881 -0.0107449627 [21] -0.0560353172 0.0480091102 -0.0900635902 -0.1738093021 0.0194828898 [26] -0.1212167233 -0.0564157708 0.0008758305 -0.1069332924 -0.0365780783 [31] 0.0570423102 -0.0744408438 -0.1030366860 0.0841034103 -0.0567224996 [36] -0.0392244322 -0.0865478229 -0.2149780072 -0.1118974085 -0.0485269017 [41] -0.0174459089 -0.0640485999 -0.0997603768 -0.0688567557 -0.0240129280 [46] 0.0228045526 -0.0203895828 -0.0215910173 -0.0129991616 > (mypacf <- c(rpacf$acf)) [1] 0.192603642 0.004719007 0.154193417 -0.045536514 0.172185717 [6] 0.159626357 -0.057918549 -0.041491398 0.032408677 -0.042652118 [11] 0.000673441 0.059889673 -0.043203435 0.162929921 0.129066259 [16] -0.056032847 -0.323438543 0.077061029 -0.014164818 -0.106377635 [21] -0.005465240 0.043132094 -0.080265411 0.038443390 -0.115634863 [26] -0.004086735 -0.039744349 -0.002126621 0.003666911 0.020833895 [31] 0.089177116 -0.020229867 0.086286912 -0.118597163 0.037448882 [36] -0.205880017 -0.123411145 -0.053060460 0.025652753 0.051117334 [41] 0.032215763 -0.078461209 0.062137354 -0.017746975 -0.084312972 [46] -0.024092663 0.021985185 0.019285839 > 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/4ep4n1395088388.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/5ww041395088388.tab") > > try(system("convert tmp/12p8i1395088388.ps tmp/12p8i1395088388.png",intern=TRUE)) character(0) > try(system("convert tmp/2eq5y1395088388.ps tmp/2eq5y1395088388.png",intern=TRUE)) character(0) > try(system("convert tmp/3nuez1395088388.ps tmp/3nuez1395088388.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.889 0.482 3.366