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(1160,1220,1100,1030,1110,1160,1170,1090,1160,1210,1250,1200,1180,1210,950,1070,1120,1220,1170,1120,1180,1250,1240,1230,1120,1330,990,1110,1090,1210,1220,1220,1100,1200,1320,1180,1110,1300,1060,1130,1160,1260,1210,1190,1130,1170,1370,1170,1040,1340,1050,1130,1150,1220,1210,1150,1130,1150,1440,1160,1130,1350,1050,1150,1120,1170,1100,1120,1210,1170,1370,1170,1110,1320,1060,1150,1160,1230,1140,1100,1270,1160,1380,1150,1180,1370,1080,1160,1230,1210,1130,1110,1250,1210,1370,1080,1220,1360,1120,1150,1180,1250,1040,1180,1250,1120,1430,1150) > 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/wessaorg/rcomp/tmp/1z9t11344779196.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/22c2m1344779196.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/3yzhr1344779196.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.183922154 -0.064857640 0.125865940 -0.076290265 [6] -0.002689779 -0.196314101 0.022976634 -0.142256585 0.165891311 [11] -0.057341210 -0.153710816 0.773038295 -0.172085772 -0.050089441 [16] 0.074660620 -0.025923028 -0.032144089 -0.152055749 0.041167152 [21] -0.211509728 0.155892219 -0.078330800 -0.133815753 0.619827922 [26] -0.185052299 -0.031886711 0.057578763 -0.012860391 -0.019101805 [31] -0.118351328 0.029296622 -0.252599718 0.131791707 -0.075760019 [36] -0.092433247 0.479256622 -0.153177592 -0.019485539 0.079032849 [41] 0.018794506 -0.046749805 -0.115330750 0.046679136 -0.245034366 [46] 0.110797028 -0.067210610 -0.049442873 0.370473303 > (mypacf <- c(rpacf$acf)) [1] -0.1839221542 -0.1021401301 0.0982466675 -0.0415080089 -0.0085479073 [6] -0.2316347289 -0.0496882334 -0.1999672959 0.1693899258 -0.0651794184 [11] -0.1314183104 0.7297243603 0.0298269662 0.0165022449 -0.0334457841 [16] -0.0071165249 -0.0128432392 0.0706806264 0.0125095146 -0.0967273051 [21] -0.1036306228 -0.1023182704 -0.0461991150 0.0776955854 -0.0706633860 [26] -0.0134182535 0.0081739386 -0.0942477346 0.0958833327 0.0279310224 [31] -0.0399173724 -0.0413556774 -0.0824676524 -0.0005781247 0.0800317960 [36] -0.0113486615 0.0618381583 -0.0327280371 0.0692522529 0.0404170201 [41] -0.0190372749 -0.0932502518 0.0343220765 0.0533993716 -0.0035318588 [46] 0.0146697800 0.0100013089 -0.0700901124 > 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/4celq1344779196.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/57rse1344779196.tab") > > try(system("convert tmp/1z9t11344779196.ps tmp/1z9t11344779196.png",intern=TRUE)) character(0) > try(system("convert tmp/22c2m1344779196.ps tmp/22c2m1344779196.png",intern=TRUE)) character(0) > try(system("convert tmp/3yzhr1344779196.ps tmp/3yzhr1344779196.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.626 0.323 1.939