R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(3862.5,3875.7,3875.9,3877.7,3880.4,3883.4,3884.2,3884.8,3894.9,3903.3,3911.2,3928.9,3945.6,3965.7,3992.3,4008.7,4014.8,4020.6,4037.5,4058.5,4082.3,4102.4,4127.1,4144.4,4161,4168.2,4178.3,4174.1,4165.7,4167.9,4158.3,4158.3,4143.7,4157.5,4164.8,4173.9,4181.2,4190.7,4206.6,4222.1,4245.8,4255.4,4266.1,4273.6,4282.1,4299.8,4315.7,4331.7,4348.4,4367.8,4387.2,4410.9,4436,4453.8,4469.1,4472,4458.2,4449,4441.5,4445.7,4453.9,4469.7,4487.5,4504,4524.1,4540.5,4548.4,4554.2,4558,4557.5,4554.5,4550,4543.8,4538.2,4543.3,4545.1) > 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/1s1pz1425481743.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/2lp0r1425481743.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/3fk391425481743.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.968141519 0.934753349 0.899138738 0.861098775 [6] 0.821006724 0.779328541 0.736233362 0.691890772 0.647727246 [11] 0.603558549 0.559430848 0.516788318 0.475802449 0.436503313 [16] 0.399659895 0.364297753 0.329049544 0.293760669 0.258657839 [21] 0.223977895 0.189606391 0.156474471 0.125977386 0.097523089 [26] 0.071471412 0.046602108 0.022767290 -0.001345126 -0.026404407 [31] -0.051315133 -0.077098101 -0.102505857 -0.129562030 -0.155441746 [36] -0.180444893 -0.204442176 -0.226486917 -0.247122909 -0.265818571 [41] -0.283286090 -0.298938804 -0.313959247 -0.328191699 -0.341318142 [46] -0.355402264 -0.368327800 -0.380979776 -0.392359547 > (mypacf <- c(rpacf$acf)) [1] 0.9681415185 -0.0405832541 -0.0522570583 -0.0560375032 -0.0507280718 [6] -0.0440338052 -0.0423451198 -0.0409562336 -0.0193658260 -0.0235644520 [11] -0.0245740144 -0.0029624815 -0.0013172072 -0.0021788275 0.0087747972 [16] -0.0080585997 -0.0310025843 -0.0344179820 -0.0308463562 -0.0258114243 [21] -0.0269237888 -0.0115523275 0.0126487294 0.0039614784 0.0090075181 [26] -0.0108327056 -0.0138448798 -0.0361054112 -0.0483368515 -0.0311119086 [31] -0.0468212475 -0.0264782467 -0.0575652146 -0.0104281250 -0.0128269214 [36] -0.0098028800 0.0051700414 -0.0049438240 -0.0002877627 -0.0158071295 [41] -0.0102293546 -0.0309301278 -0.0291148705 -0.0226367383 -0.0526358114 [46] -0.0157007792 -0.0270866945 -0.0078771616 > 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/4xcg81425481743.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/5idk91425481743.tab") > > try(system("convert tmp/1s1pz1425481743.ps tmp/1s1pz1425481743.png",intern=TRUE)) character(0) > try(system("convert tmp/2lp0r1425481743.ps tmp/2lp0r1425481743.png",intern=TRUE)) character(0) > try(system("convert tmp/3fk391425481743.ps tmp/3fk391425481743.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.255 0.219 1.480