R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(3028,3017,3007,2986,3193,3183,3028,2924,2935,2935,2945,2966,2955,3038,3069,3038,3152,3079,2914,2873,2873,2893,2811,2873,2821,2873,2955,2986,3059,3028,2842,2769,2738,2769,2718,2738,2676,2780,2831,2842,3038,3038,2780,2718,2718,2749,2614,2552,2480,2501,2594,2521,2718,2749,2552,2480,2439,2480,2366,2325,2160,2201,2211,2222,2418,2397,2160,2056,2015,2067,1870,1736,1488,1509,1509,1488,1664,1674,1467,1426,1343,1457,1250,1126,889,940,878,899,1054,1085,982,971,971,1106,868,713,444,661,630,641,889,858,744,796,796,982,765,641,444,703,682,692,909,889,816,827,878,992,816,672) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/www/rcomp/tmp/1hqvq1343994739.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/www/rcomp/tmp/2ugto1343994739.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/www/rcomp/tmp/3p0jm1343994739.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.97755843 0.95635755 0.93892667 0.92222140 0.90223838 [7] 0.88172723 0.86473720 0.84965413 0.83175505 0.81611021 0.80182429 [13] 0.78238211 0.75241105 0.72263331 0.69637482 0.66955680 0.64049810 [19] 0.61027248 0.58433549 0.56048203 0.53434351 0.51014077 0.48886981 [25] 0.46251549 0.42953143 0.39772169 0.36906199 0.33965000 0.30799365 [31] 0.27476103 0.24579560 0.21890632 0.19199745 0.16634908 0.14436770 [37] 0.12054419 0.09194404 0.06391235 0.03891112 0.01320600 -0.01533249 [43] -0.04593299 -0.07021534 -0.09214186 -0.11484533 -0.13594991 -0.15320101 [49] -0.17051800 > (mypacf <- c(rpacf$acf)) [1] 0.977558428 0.016608262 0.074891437 0.012153402 -0.074819088 [6] -0.023484131 0.057591042 0.034292215 -0.054429035 0.049413360 [11] 0.009413412 -0.126670908 -0.246909344 -0.050056662 0.016757291 [16] -0.017791251 -0.020284052 -0.058036229 0.026767706 0.020559583 [21] -0.040994608 0.015392212 0.048920483 -0.078695289 -0.116541613 [26] -0.017672199 -0.001877121 -0.018066477 -0.015040930 -0.074652026 [31] -0.004404214 0.011727578 0.009090233 -0.013202120 0.056993308 [36] 0.006280907 -0.076397328 -0.030910167 -0.002782502 -0.020687385 [41] -0.024736520 -0.071764076 0.036627232 0.011996989 -0.014116510 [46] -0.014997619 0.032006520 0.018614229 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/4zv351343994739.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/www/rcomp/tmp/5i5ys1343994739.tab") > > try(system("convert tmp/1hqvq1343994739.ps tmp/1hqvq1343994739.png",intern=TRUE)) character(0) > try(system("convert tmp/2ugto1343994739.ps tmp/2ugto1343994739.png",intern=TRUE)) character(0) > try(system("convert tmp/3p0jm1343994739.ps tmp/3p0jm1343994739.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.870 0.600 1.418