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(101.1,101.35,101.45,101.49,101.68,101.92,102.04,102.55,104.02,105.41,105.48,105.54,105.16,105.16,105.16,105.16,105.16,105.17,105.17,105.54,106.9,107.27,107.31,107.39,107.41,107.46,113.14,117,119.28,119.39,119.5,119.67,119.67,119.73,119.77,119.77,119.78,119.78,119.78,121.28,122.44,122.72,122.75,122.8,122.81,122.83,122.83,122.83,122.84,122.85,123.61,124.74,125.1,125.29,125.45,125.51,125.55,125.57,125.81,127.41,127.75,127.76,127.8,128.23,130.01,130.07,130.17,130.21,130.22,130.23,130.23,130.23,130.23,130.24,130.13,130.14,130.79,131.38,131.61,131.72,131.89,131.89,131.96,131.99,132,132.06,132.11,132.88,135.48,136.56,136.96,137.4,138.32,138.82,138.96,138.94,139,139.19,139.22,139.37,140.74,141.17,141.51,142.94,144.81,145.41,146.11,146.23) > 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/1o6bk1413655491.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/2jyzn1413655491.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/34ntt1413655491.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.479486266 0.077431490 -0.107915249 -0.095348090 [6] -0.083993718 -0.048322123 -0.068093439 -0.086023427 -0.129675761 [11] -0.126427186 0.005269967 0.127835336 0.127176766 -0.035317710 [16] -0.095854752 -0.093679947 -0.018578471 0.047376177 0.041758593 [21] -0.024607536 -0.109153158 -0.109080984 -0.035320261 0.088286426 [26] 0.054415574 -0.045359848 -0.059537822 -0.036026804 -0.026726169 [31] -0.026795910 0.025430425 0.051098987 0.067660670 -0.068492179 [36] -0.088429099 0.022500427 0.092779698 0.096403073 -0.029486238 [41] -0.027565136 -0.034392908 -0.045407632 -0.059220326 -0.035096881 [46] -0.057170595 -0.091893419 -0.094151198 -0.044500552 > (mypacf <- c(rpacf$acf)) [1] 0.4794862657 -0.1979963521 -0.0776549174 0.0191630488 -0.0668273428 [6] 0.0013607272 -0.0720565090 -0.0493318418 -0.0964485583 -0.0525652478 [11] 0.0978229667 0.0609086024 -0.0055008448 -0.1404040209 0.0006648581 [16] -0.0373294181 0.0213808200 0.0353049733 -0.0387598913 -0.0435822230 [21] -0.0819392242 -0.0002780861 0.0050078497 0.0546552681 -0.0849105001 [26] -0.0701965475 0.0511739245 -0.0281298910 -0.0380773860 -0.0665024522 [31] 0.0356627238 0.0252597442 0.0631015871 -0.1462225878 -0.0291134882 [36] 0.0737372989 0.0023785243 0.0856331472 -0.1433557374 0.0682814643 [41] -0.0470813054 -0.0443878883 -0.0169767275 -0.0643744281 -0.0407429953 [46] -0.0799746032 0.0279073058 -0.0605196165 > 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/4x2hn1413655491.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/5257x1413655491.tab") > > try(system("convert tmp/1o6bk1413655491.ps tmp/1o6bk1413655491.png",intern=TRUE)) character(0) > try(system("convert tmp/2jyzn1413655491.ps tmp/2jyzn1413655491.png",intern=TRUE)) character(0) > try(system("convert tmp/34ntt1413655491.ps tmp/34ntt1413655491.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.158 0.205 1.365