R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(45.3,49.9,53.8,55.1,52.9,53.5,53.8,52,48.2,45.5,45.7,52.5,52.3,54.8,54.7,54.9,54.9,64.2,66.4,69.1,68.3,77.3,89.6,93,96.1,131.3,125.3,126,138.3,163,182.5,164.6,148.8,109.3,93.5,80.2,84,75.5,62.4,64.2,64.7,71,73.7,72.6,68.1,72.3,78.5,81.9,97.8,93.1,94.2,101.1,101,99.7,97.1,91.7,95,98.9,109,121.9,131.5,128.5,128.4,126.4,123.1,123,123.3,123.6,124.9,120.4,114.9,113.4) > 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/14bcy1354102274.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/2f3kv1354102274.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/35w591354102274.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.3905996664 0.1846793112 -0.0100713563 0.0013149933 [6] 0.0373241060 -0.0379949796 -0.0160011712 -0.2225186962 -0.1957851355 [11] -0.1984966137 -0.0122515579 -0.0427421735 -0.2007379729 -0.1286811432 [16] -0.1802280253 -0.0882168109 -0.0106748113 0.0428607814 0.0260511344 [21] -0.0222211845 -0.0380518714 -0.0364758021 0.0817930800 -0.0375932823 [26] -0.1078178994 -0.0379179116 -0.0442901989 0.0482517146 0.1218425064 [31] 0.1039022618 0.0912960400 0.0007757527 0.0156135864 0.0555833722 [36] 0.0748183084 0.0329368484 0.0787582240 0.0414525143 -0.0142465863 [41] -0.0350109585 -0.0396768182 -0.0323958934 -0.0041783833 -0.0408921250 [46] -0.0242198043 -0.0045275468 -0.0009291971 -0.0145949198 > (mypacf <- c(rpacf$acf)) [1] 3.905997e-01 3.789238e-02 -1.114071e-01 4.059777e-02 5.412149e-02 [6] -9.434928e-02 1.964939e-02 -2.375011e-01 -5.411090e-02 -6.396731e-02 [11] 1.040719e-01 -9.032847e-02 -2.193733e-01 2.961645e-02 -1.091060e-01 [16] -8.518254e-02 5.136130e-02 -4.176476e-02 -2.780454e-02 -2.282290e-02 [21] -1.178873e-01 -7.815048e-02 3.968099e-02 -1.582873e-01 -1.831102e-01 [26] 5.523744e-02 -6.866297e-02 -5.463858e-02 8.988916e-02 -8.043415e-02 [31] -8.361154e-05 -5.877424e-02 -5.933127e-02 -4.026377e-02 -1.277268e-02 [36] 6.871188e-03 2.509543e-02 -3.903689e-02 -8.859751e-03 -1.477115e-01 [41] -1.780923e-02 4.304992e-04 1.035234e-02 -1.113952e-02 2.139449e-02 [46] -2.738990e-02 9.122767e-03 -5.390421e-02 > 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/4mdtu1354102274.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/5rah71354102274.tab") > > try(system("convert tmp/14bcy1354102274.ps tmp/14bcy1354102274.png",intern=TRUE)) character(0) > try(system("convert tmp/2f3kv1354102274.ps tmp/2f3kv1354102274.png",intern=TRUE)) character(0) > try(system("convert tmp/35w591354102274.ps tmp/35w591354102274.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.902 0.403 2.282