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(98.19,98.19,98.19,98.19,98.19,98.19,98.19,100.48,102.78,102.78,102.78,102.78,102.78,102.78,102.78,102.78,102.78,102.78,102.78,101.67,101.67,101.67,101.67,101.67,101.67,101.67,101.67,101.67,101.67,101.67,101.67,105.79,105.79,105.79,105.79,105.79,105.79,105.79,105.79,105.79,105.79,105.79,105.79,104.47,104.47,104.47,104.47,104.47,104.47,104.47,104.47,105.5,105.5,105.5,105.5,106.61,106.61,106.61,106.61,106.61) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > 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/www/rcomp/tmp/1mkr31333576395.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/2o65x1333576395.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/3dme41333576395.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.0000000000 0.1281102339 -0.0393473379 -0.0399923762 -0.0044276614 [6] -0.0362654030 -0.0369104413 -0.0272049893 -0.0605145856 -0.0134439164 [11] -0.0140889547 -0.0955907232 -0.4593689425 -0.0160240697 -0.0166691080 [16] -0.0173141463 -0.0179591846 -0.0245704444 -0.0252154828 -0.0308775710 [21] 0.1028775553 -0.0321676476 -0.0328126859 0.2666591481 0.4559529982 [26] -0.0347478009 -0.0353928392 -0.0360378776 -0.0366829159 -0.0187061114 [31] -0.0193511498 -0.0013743453 -0.0382291367 -0.0026644220 -0.0033094603 [36] -0.1001084480 -0.1393575868 -0.0052445753 -0.0058896136 -0.0065346519 [41] -0.0071796902 -0.0128417784 -0.0134868168 0.0549311415 0.0539598892 [46] -0.0213881532 -0.0220331915 0.0581785003 0.0571819110 -0.0239683065 [51] -0.0246133448 -0.0206029225 -0.0108522719 -0.0011468199 -0.0017918582 [56] 0.0025801533 0.0019351150 0.0012900767 0.0006450383 > (mypacf <- c(rpacf$acf)) [1] 1.281102e-01 -5.668998e-02 -2.795033e-02 2.472134e-03 -4.002719e-02 [6] -2.869961e-02 -2.239274e-02 -6.109100e-02 -2.204476e-03 -2.123331e-02 [11] -1.015319e-01 -4.559614e-01 8.170411e-02 -1.092578e-01 -6.443227e-02 [16] -5.460150e-02 -1.047560e-01 -9.825018e-02 -1.101400e-01 2.648506e-02 [21] -1.485966e-01 -1.075071e-01 2.385666e-01 2.178207e-01 -1.087688e-01 [26] -2.759455e-02 -3.610989e-02 -5.310902e-02 -3.682399e-02 -2.405475e-02 [31] -3.207718e-02 5.750233e-02 -6.753055e-02 -3.604156e-02 1.313618e-01 [36] 1.503645e-01 -1.099599e-01 3.959351e-02 1.692357e-02 -4.797265e-02 [41] 2.458925e-02 4.361294e-02 3.924993e-02 -7.339620e-03 5.825264e-02 [46] -8.288447e-02 -1.838153e-01 -2.768773e-02 -3.901927e-03 -3.270850e-02 [51] 7.833363e-05 -2.969156e-02 -1.064758e-02 -1.993137e-02 -1.325783e-03 [56] -5.253188e-02 3.861876e-02 -5.626412e-02 > 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/4r9hy1333576395.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/578b41333576395.tab") > > try(system("convert tmp/1mkr31333576395.ps tmp/1mkr31333576395.png",intern=TRUE)) character(0) > try(system("convert tmp/2o65x1333576395.ps tmp/2o65x1333576395.png",intern=TRUE)) character(0) > try(system("convert tmp/3dme41333576395.ps tmp/3dme41333576395.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.390 0.150 1.528