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(219.20,232.50,235.60,171.00,165.90,187.60,218.20,249.80,256.50,224.90,200.00,182.50,230.30,252.80,270.60,196.90,184.70,202.50,258.20,283.10,268.50,283.80,231.10,212.10,238.50,262.80,245.50,198.20,167.20,184.20,254.90,246.40,264.50,242.40,186.70,254.70,230.10,253.60,228.00,183.80,150.00,178.50,228.40,228.70,236.70,218.20,173.50,189.10,194.60,213.70,216.30,173.90,156.90,182.90,216.40,234.00,257.30,225.70,201.70,189.20) > 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/141k21337779183.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/29vzu1337779183.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/3rt7x1337779183.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.531560659 -0.032212959 -0.358828225 -0.219000796 [6] 0.226673908 0.430884501 0.241877725 -0.193944828 -0.377675552 [11] -0.165301565 0.328117832 0.600222028 0.299717516 -0.145596674 [16] -0.436507820 -0.293930228 0.032167772 0.189719413 0.050634120 [21] -0.256620630 -0.352359453 -0.197113333 0.196872087 0.319382753 [26] 0.127420932 -0.229674279 -0.396482357 -0.236911011 -0.018099868 [31] 0.098501823 -0.009670701 -0.240063669 -0.276596032 -0.126759589 [36] 0.138822925 0.246872975 0.126876378 -0.101586683 -0.203439515 [41] -0.125930814 0.020109034 0.137220439 0.098585748 -0.028879753 [46] -0.099196856 -0.034805845 0.073484078 0.146788434 > (mypacf <- c(rpacf$acf)) [1] 0.531560659 -0.438738098 -0.174295371 0.197230068 0.337346871 [6] -0.023060791 -0.119778330 -0.186852568 0.090432546 0.114520571 [11] 0.314262072 0.144836484 -0.252232742 -0.006323959 -0.058302926 [16] -0.072613905 -0.233103301 -0.155609121 -0.013375173 0.033166552 [21] 0.066865718 -0.112464191 0.086283960 -0.105488969 0.042219587 [26] -0.157934611 0.044122848 -0.033640631 -0.075426550 -0.036691736 [31] 0.068565178 -0.147489079 0.025113792 -0.081731055 -0.046820344 [36] 0.076589076 0.070943517 0.086750226 -0.040910690 -0.053697869 [41] 0.027635050 0.074999958 0.079967107 -0.069311680 -0.045809655 [46] 0.006524863 -0.079248831 -0.123725811 > 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/4l4fz1337779183.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/5qeyb1337779183.tab") > > try(system("convert tmp/141k21337779183.ps tmp/141k21337779183.png",intern=TRUE)) character(0) > try(system("convert tmp/29vzu1337779183.ps tmp/29vzu1337779183.png",intern=TRUE)) character(0) > try(system("convert tmp/3rt7x1337779183.ps tmp/3rt7x1337779183.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.090 0.280 1.367