R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(599,599,599,599,599,599,599,599,599,617.06,617.06,617.06,617.06,617.06,617.06,617.06,617.06,617.06,617.06,617.06,617.06,628.18,628.18,628.18,628.18,628.18,628.18,628.18,628.18,628.18,628.18,628.18,628.18,641.08,641.08,641.08,641.08,641.08,641.08,641.08,641.08,641.08,641.08,641.08,641.08,668.21,668.21,668.21,668.21,668.21,668.21,668.21,668.21,668.21,668.21,668.21,668.21,665.27,665.27,665.27,665.27,665.27,665.27,665.27,665.27,665.27,665.27,665.27,665.27,674.3,674.3,674.3) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'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/126ku1363346920.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/2r5gf1363346920.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/3rne71363346920.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.059434810 -0.060260294 -0.054057328 -0.054882811 [6] -0.055708295 -0.056533778 -0.057359262 -0.058184745 -0.044953331 [11] -0.045778814 -0.046604298 0.384058958 -0.048255264 -0.049080748 [16] -0.052194564 -0.053020047 -0.053845531 -0.054671014 -0.055496498 [21] -0.056321981 -0.048492276 -0.049317759 -0.050143243 0.493375542 [26] -0.051794210 -0.052619693 -0.032328695 -0.033154179 -0.033979662 [31] -0.034805146 -0.035630629 -0.036456113 -0.027240955 -0.028066438 [36] -0.028891922 0.391364821 -0.030542889 -0.031368372 -0.022153214 [41] -0.022978697 -0.023804181 -0.024629664 -0.025455148 -0.026280631 [46] -0.005989634 -0.006815117 -0.007640600 0.026259868 -0.009291567 [51] -0.010117051 -0.002287346 -0.003112829 -0.003938313 -0.004763796 [56] -0.005589280 -0.006414763 -0.009528579 -0.010354062 -0.011179546 [61] 0.107680219 > (mypacf <- c(rpacf$acf)) [1] -0.0594348102 -0.0640189370 -0.0621464631 -0.0670726769 -0.0727045514 [6] -0.0792638556 -0.0869487031 -0.0960926831 -0.0924788473 -0.1025631303 [11] -0.1149431083 0.3352757037 -0.0460350242 -0.0480133368 -0.0599250659 [16] -0.0666977000 -0.0716285392 -0.0773890085 -0.0840664573 -0.0919448036 [21] -0.1049464226 -0.1189855798 -0.1353411368 0.3305908125 -0.0575394750 [26] -0.0601359984 -0.0379704198 -0.0429273677 -0.0422078908 -0.0415835546 [31] -0.0410159772 -0.0401370904 -0.0464832992 -0.0479038132 -0.0479119124 [36] 0.1213369558 -0.0152216380 -0.0118205686 -0.0030620458 -0.0039541662 [41] 0.0008544288 0.0067682288 0.0129386105 0.0198572149 0.0411988677 [46] 0.0498601994 0.0618550669 -0.4105685496 0.0006084239 0.0053807015 [51] -0.0055044133 -0.0002221427 0.0035207381 0.0063672170 0.0089483749 [56] 0.0118415272 0.0026305060 0.0056912952 0.0069358267 -0.0944511664 > 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/4g3ss1363346920.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/5hq9o1363346920.tab") > > try(system("convert tmp/126ku1363346920.ps tmp/126ku1363346920.png",intern=TRUE)) character(0) > try(system("convert tmp/2r5gf1363346920.ps tmp/2r5gf1363346920.png",intern=TRUE)) character(0) > try(system("convert tmp/3rne71363346920.ps tmp/3rne71363346920.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.018 0.285 2.280