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(412,406,398,397,385,390,413,413,401,397,397,409,419,424,428,430,424,433,456,459,446,441,439,454,460,457,451,444,437,443,471,469,454,444,436,442,446,442,438,433,428,426,452,455,439,434,431,435,450,449,442,437,431,433,460,465,451,447,446,449,460,457,454,453,449,451,482,486,476,472,471,479) > 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/1r69b1413729276.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/2koni1413729276.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/3hanh1413729276.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.00000000 0.21526287 -0.44415099 -0.36846911 -0.21675933 0.19813633 [7] 0.50551520 0.19801015 -0.18889687 -0.35398800 -0.41892951 0.12996860 [13] 0.74793377 0.16712060 -0.41257610 -0.35242030 -0.19465920 0.14456932 [19] 0.40182877 0.16386358 -0.18513868 -0.32889165 -0.35051315 0.08416179 [25] 0.59387347 0.18648083 -0.31533860 -0.26885761 -0.14572023 0.07262051 [31] 0.27349845 0.16933444 -0.11185013 -0.21377361 -0.23146280 0.03438470 [37] 0.43580681 0.17454204 -0.24191904 -0.18880950 -0.09279199 0.04489551 [43] 0.20519524 0.13719674 -0.08046891 -0.13293942 -0.16264960 0.01813954 [49] 0.27818066 > (mypacf <- c(rpacf$acf)) [1] 0.215262872 -0.514321795 -0.161067547 -0.435622442 0.109500654 [6] 0.183490451 0.154057078 0.153105218 -0.050314887 -0.404028979 [11] 0.042091416 0.434122628 -0.260020972 -0.056533424 -0.057267925 [16] 0.028574385 -0.127421080 -0.106182613 -0.017072607 -0.105029587 [21] -0.055150985 -0.058332598 -0.095147123 -0.026088743 0.004823441 [26] 0.043551422 0.079652032 0.001218066 -0.101595644 -0.193373778 [31] -0.024869553 -0.137590813 0.046667665 -0.009830483 -0.001362880 [36] 0.002997079 0.005294909 -0.036697497 -0.053152529 -0.093746088 [41] 0.007308673 -0.048895409 -0.096006495 -0.059822505 0.003658180 [46] -0.030031980 0.106505504 -0.156430588 > 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/4jyzg1413729276.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/5sarr1413729276.tab") > > try(system("convert tmp/1r69b1413729276.ps tmp/1r69b1413729276.png",intern=TRUE)) character(0) > try(system("convert tmp/2koni1413729276.ps tmp/2koni1413729276.png",intern=TRUE)) character(0) > try(system("convert tmp/3hanh1413729276.ps tmp/3hanh1413729276.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.132 0.212 1.351