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(181896,181580,181234,180598,187123,186807,181896,178638,178954,178954,179269,179936,181580,179616,181580,179936,185158,187469,177656,175025,177305,176989,175025,175345,179269,178638,179269,179269,183545,184176,172398,172398,176989,174709,170785,172398,176327,174363,174047,169803,176007,177305,164545,164229,170785,167176,160967,163598,166509,167176,165212,161287,169456,169456,155078,154101,158025,150838,143616,145932,150838,146910,144283,138710,146247,146563,132190,131839,134470,126301,117465,121043,125950,120728,120412,115154,123670,125319,109266,105688,107968,99132,89981,92928,98470,91946,92928,89004,97172,98150,78524,77221,80799,71333,62817,65764,72950,64462,63799,57244,64462,66742,46448,46448,49391,41542,32706,37297,45466,36631,40244,35333,43186,45813,24853,23240,26502,18649,12444,15040) > 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/1k9vs1344691816.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/2omxk1344691816.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/3kdu21344691816.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.970504236 0.941070058 0.919919026 0.897951413 [6] 0.868974990 0.840659964 0.824634681 0.808242011 0.784392016 [11] 0.759196871 0.738479080 0.720988276 0.688780618 0.656217211 [16] 0.632139800 0.607469821 0.576267571 0.545225755 0.526410276 [21] 0.507027756 0.480531542 0.453875377 0.432653840 0.414353710 [26] 0.383047027 0.351635489 0.328220095 0.304648079 0.275148405 [31] 0.246909687 0.230450718 0.213329359 0.189150055 0.164917313 [36] 0.145128636 0.127298545 0.098766782 0.070348134 0.049511487 [41] 0.029273634 0.003793049 -0.019538903 -0.032627577 -0.046780081 [46] -0.067601350 -0.087303016 -0.102399236 -0.116014085 > (mypacf <- c(rpacf$acf)) [1] 0.9705042355 -0.0139090162 0.1273789985 -0.0255221942 -0.1143582991 [6] -0.0072596533 0.1726918816 -0.0110682513 -0.0850673366 -0.0463008411 [11] 0.0059140984 0.0491684602 -0.2131357638 -0.0130826660 0.0473048917 [16] -0.0370381993 -0.0577365200 -0.0029766717 0.0993659482 -0.0275997792 [21] -0.0432235089 -0.0206013983 0.0073992367 0.0224530182 -0.1368907326 [26] -0.0071575136 0.0099747027 -0.0287974063 -0.0349028920 0.0235038220 [31] 0.0611911769 -0.0300893931 -0.0325851412 -0.0239845772 -0.0193183979 [36] -0.0010508790 -0.0786609972 -0.0107036396 -0.0063132810 -0.0164182159 [41] -0.0232451157 0.0368749856 0.0225831099 -0.0334282391 -0.0250354731 [46] -0.0053977709 -0.0129171443 0.0002255466 > 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/4xte81344691816.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/5a1bb1344691816.tab") > > try(system("convert tmp/1k9vs1344691816.ps tmp/1k9vs1344691816.png",intern=TRUE)) character(0) > try(system("convert tmp/2omxk1344691816.ps tmp/2omxk1344691816.png",intern=TRUE)) character(0) > try(system("convert tmp/3kdu21344691816.ps tmp/3kdu21344691816.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.563 0.330 1.856