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(1095,1085,1075,1054,1261,1250,1095,992,1002,1002,1013,1033,1095,1075,1106,1157,1447,1447,1385,1323,1374,1436,1447,1478,1571,1509,1509,1602,1860,1881,1829,1705,1798,1798,1808,1860,1901,1922,1922,1984,2222,2284,2294,2139,2222,2191,2129,2263,2294,2242,2253,2325,2594,2728,2728,2666,2759,2666,2614,2811,2842,2769,2955,3028,3245,3389,3369,3358,3441,3431,3307,3493,3555,3493,3751,3875,4164,4278,4247,4185,4237,4299,4092,4257,4361,4319,4588,4681,5074,5146,5053,5105,5136,5167,4970,5156,5259,5156,5456,5549,5952,6014,6034,6138,6138,6179,5993,6086,6148,6034,6365,6427,6840,6913,7016,7109,7119,7130,6944,7130) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/15j1h1408300399.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/2jnmb1408300399.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/3jktn1408300399.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.974719001 0.950394798 0.923515543 0.895874891 [6] 0.869072671 0.842312158 0.816446634 0.789800498 0.766717683 [11] 0.743586341 0.722907024 0.700636979 0.675178823 0.649833770 [16] 0.622246638 0.594465023 0.567805636 0.541511582 0.515622791 [21] 0.489258798 0.466548357 0.444630780 0.425050627 0.404082210 [26] 0.381288350 0.359169331 0.334733096 0.310251091 0.286982452 [31] 0.263937674 0.240166136 0.215912216 0.195336443 0.175408522 [36] 0.157582110 0.139019322 0.119111652 0.100156567 0.079029139 [41] 0.057996598 0.038273202 0.018142460 -0.001972435 -0.022261859 [46] -0.039939032 -0.056615364 -0.071657301 -0.087163104 -0.103813472 [51] -0.119634235 -0.136567314 -0.153919788 -0.169468499 -0.184434267 [56] -0.199431209 -0.213685881 -0.225838965 -0.237559697 -0.248251570 [61] -0.259062633 > (mypacf <- c(rpacf$acf)) [1] 9.747190e-01 6.363160e-03 -6.330005e-02 -3.119576e-02 4.172927e-03 [6] -1.120221e-02 2.051568e-03 -3.005558e-02 5.482265e-02 -1.044245e-02 [11] 3.025576e-02 -4.571146e-02 -8.093038e-02 -1.401438e-02 -4.949498e-02 [16] -2.327593e-02 1.296780e-02 -8.738677e-03 -6.111741e-03 -3.035479e-02 [21] 4.836891e-02 2.176090e-03 1.735333e-02 -4.315346e-02 -5.301835e-02 [26] -7.509615e-05 -4.697845e-02 -2.507042e-02 1.651305e-02 -1.136783e-02 [31] -2.635688e-02 -3.543445e-02 4.593497e-02 -2.603209e-03 4.302893e-03 [36] -3.221465e-02 -4.507959e-02 5.673367e-03 -4.436439e-02 -2.829650e-02 [41] 1.853587e-02 -2.283805e-02 -8.325183e-03 -2.999735e-02 2.164385e-02 [46] 3.934366e-03 -9.768075e-03 -3.004914e-02 -4.204912e-02 1.124049e-03 [51] -2.225789e-02 -4.386994e-02 2.684647e-02 2.145315e-03 -1.062916e-02 [56] -1.325803e-02 1.165984e-02 -7.905581e-03 -2.242070e-02 -2.542238e-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/41leq1408300399.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/5hw9a1408300399.tab") > > try(system("convert tmp/15j1h1408300399.ps tmp/15j1h1408300399.png",intern=TRUE)) character(0) > try(system("convert tmp/2jnmb1408300399.ps tmp/2jnmb1408300399.png",intern=TRUE)) character(0) > try(system("convert tmp/3jktn1408300399.ps tmp/3jktn1408300399.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.256 0.169 1.439