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(13671,15698,18150,16245,18479,18479,18819,18059,17004,16981,16578,21604,13419,14487,17349,15646,17419,17358,18221,19554,14386,16833,18067,19662,12192,15081,13698,18474,13871,15669,17597,15469,15374,16568,11619,16780,8700,8906,9612,10073,10275,9921,13237,9572,10425,11385,9970,15456,7708,8892,11145,11069,9893,10929,12240,10411,9747,9950,10079,14064,8368,9558,10432,10068,9915,9549,10433,10009,10327,9453,9494,13133,7082,7805,9064,8236,10182,16210,7451,8384,7143,8507,9833,17364,6260,7897,8933,6554,8333,7224,9659,9977,9289,9929,10576,15463) > 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/1wzum1432631448.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/2pbrx1432631448.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/38gjd1432631448.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.506300309 0.037726635 0.019276466 -0.033018818 [6] 0.012119761 0.072191508 -0.089729859 0.060075998 0.015535222 [11] -0.043142451 -0.274037938 0.489246391 -0.257729017 0.070971786 [16] -0.033128151 0.013315918 0.014270584 -0.042750138 0.017898890 [21] 0.022473642 0.004409589 -0.013067494 -0.225618979 0.407988534 [26] -0.227903112 0.049853422 -0.034461244 0.004624694 0.060480176 [31] -0.062877990 0.011787929 0.034261526 -0.007528721 -0.046644767 [36] -0.174160021 0.341339427 -0.182393376 0.033533413 -0.019866553 [41] -0.032805336 0.075643924 -0.034405104 -0.037783561 0.084087392 [46] -0.027037404 -0.003941378 -0.165277594 0.264392642 > (mypacf <- c(rpacf$acf)) [1] -0.506300309 -0.293969514 -0.154320200 -0.124760935 -0.087499090 [6] 0.052273065 -0.014074132 0.027911041 0.078238062 0.033286263 [11] -0.440401722 0.139404457 0.086750955 0.079987104 0.003198534 [16] 0.099263203 0.091256008 -0.123721728 -0.002275335 -0.007176412 [21] -0.061693672 -0.057833558 -0.136887567 0.186747395 0.087001279 [26] 0.032900961 -0.007289240 -0.046161146 -0.003371318 -0.050388411 [31] 0.001182187 0.021037754 -0.007389941 -0.057502279 -0.127085792 [36] 0.032853877 0.021917754 -0.051058674 0.001092378 -0.031309671 [41] -0.025824274 0.037007057 -0.036339633 0.010207750 -0.058162140 [46] 0.049171938 0.010260940 0.006323832 > 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/4c1ce1432631448.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/54wfu1432631448.tab") > > try(system("convert tmp/1wzum1432631448.ps tmp/1wzum1432631448.png",intern=TRUE)) character(0) > try(system("convert tmp/2pbrx1432631448.ps tmp/2pbrx1432631448.png",intern=TRUE)) character(0) > try(system("convert tmp/38gjd1432631448.ps tmp/38gjd1432631448.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.192 0.219 1.416