R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(530.3,527.76,521.41,1601.93,1577.49,1551.43,1551.43,1516.88,1485.95,1438.22,1385.06,1329.49,1329.49,1276.16,1242.34,1181.59,1160.21,1135.18,1135.18,1084.96,1077.35,1061.13,1029.98,1013.08,1013.08,996.04,975.02,951.89,944.4,932.47,932.47,920.44,900.18,886.9,869.74,859.03,859.03,844.99,834.82,825.62,816.92,813.21,813.21,811.03,804.16,788.62,778.76,765.91,765.91,753.85,742.22,732.11,729.94,731.22,731.22,729.11,726.94,720.52,709.36,703.21) > 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/wessaorg/rcomp/tmp/1thip1333574234.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/2a2oe1333574234.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/3apkq1333574234.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.000000e+00 -1.227115e-02 -8.771389e-03 1.725415e-02 -1.171176e-02 [6] -1.138296e-02 -2.373378e-02 -3.406454e-02 -3.526220e-02 1.275364e-02 [11] -3.548960e-02 -1.893762e-02 -4.172877e-02 -9.429795e-03 -1.317485e-02 [16] 8.826230e-03 -3.721788e-02 1.260674e-03 -5.338986e-03 -2.095458e-02 [21] -8.766308e-03 6.233559e-03 -8.879023e-03 -1.286192e-02 -1.415601e-02 [26] -1.338601e-03 -6.041153e-03 4.478963e-03 -6.498942e-03 -1.456968e-02 [31] -7.297008e-03 -1.198725e-02 -6.134001e-03 2.610431e-03 -9.772421e-03 [36] -6.360846e-03 -4.750810e-03 -5.533423e-03 -1.373863e-03 1.680811e-03 [41] -1.060509e-04 -4.902550e-03 -1.271047e-02 -8.131952e-03 -1.119464e-02 [46] 4.980254e-05 -1.124532e-02 -1.096461e-02 -9.602390e-03 -2.859932e-03 [51] -1.096814e-04 -1.644108e-03 -3.849543e-03 -3.966088e-03 -7.821115e-03 [56] -1.239418e-02 -8.030990e-03 1.349413e-04 4.154390e-05 > (mypacf <- c(rpacf$acf)) [1] -1.227115e-02 -8.923314e-03 1.703997e-02 -1.137400e-02 -1.137059e-02 [6] -2.452267e-02 -3.450823e-02 -3.640393e-02 1.174547e-02 -3.549916e-02 [11] -1.994075e-02 -4.589338e-02 -1.232331e-02 -1.760406e-02 6.254411e-03 [16] -4.132078e-02 -3.383922e-03 -1.390741e-02 -2.476852e-02 -1.655756e-02 [21] 2.491328e-03 -1.513653e-02 -1.850508e-02 -2.379297e-02 -4.707400e-03 [26] -1.396849e-02 3.440318e-05 -1.328179e-02 -1.961585e-02 -1.639351e-02 [31] -1.772882e-02 -1.339644e-02 -1.702953e-03 -1.617917e-02 -1.352628e-02 [36] -1.418479e-02 -1.096718e-02 -8.666553e-03 -4.665205e-03 -7.014734e-03 [41] -1.175588e-02 -2.206411e-02 -1.510910e-02 -1.836937e-02 -6.350590e-03 [46] -1.840376e-02 -1.867808e-02 -1.958633e-02 -1.075328e-02 -8.944175e-03 [51] -9.065050e-03 -1.289355e-02 -1.359893e-02 -1.966346e-02 -2.199963e-02 [56] -1.800678e-02 -8.564817e-03 -1.059822e-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/4udul1333574234.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/50xki1333574234.tab") > > try(system("convert tmp/1thip1333574234.ps tmp/1thip1333574234.png",intern=TRUE)) character(0) > try(system("convert tmp/2a2oe1333574234.ps tmp/2a2oe1333574234.png",intern=TRUE)) character(0) > try(system("convert tmp/3apkq1333574234.ps tmp/3apkq1333574234.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.061 0.230 1.314