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(73.97,73.97,73.97,73.97,73.97,73.97,73.96,74.44,75.43,75.77,75.82,75.85,75.85,75.85,77.95,82.07,84.82,85.08,85.34,85.65,85.65,85.72,85.73,85.73,85.73,85.73,85.74,86.32,87.59,87.81,87.87,87.94,87.96,88.01,88.01,88.01,88.01,88.01,88.59,89.43,89.63,89.73,89.88,89.89,89.9,89.91,89.86,90.07,90.17,90.17,90.28,90.87,92.05,92.1,92.16,92.22,92.25,92.29,92.29,92.29,92.29,92.29,91.95,91.82,92.16,92.31,92.33,92.4,92.54,92.49,92.54,92.58,92.58,92.39,92.33,93.59,95.51,95.99,96.22,97.2,98.54,99.64,100.23,100.17,100.28,100.44,100.54,100.64,103.27,104.31,104.97,106.42,108.17,108.68,109.15,109.19) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/1pnof1425508003.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/24elz1425508003.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/3igj71425508003.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.951948694 0.898445608 0.843668576 0.788336018 [6] 0.735847856 0.686017191 0.636542398 0.589368170 0.549973428 [11] 0.510353948 0.470008685 0.428551805 0.384692677 0.338174472 [16] 0.296622222 0.266371753 0.244943814 0.226187504 0.208390435 [21] 0.192347897 0.181122387 0.173199876 0.164760131 0.154682762 [26] 0.142985263 0.130514104 0.117883878 0.105973435 0.096754565 [31] 0.087825814 0.078797662 0.070027901 0.061885838 0.053140906 [36] 0.043226776 0.032861958 0.020915583 0.007228018 -0.006131068 [41] -0.018105930 -0.030344768 -0.042891468 -0.055462879 -0.068300964 [46] -0.078256895 -0.086748176 -0.095092447 -0.103155743 -0.111307198 [51] -0.119792339 -0.128919917 -0.137281904 -0.143733761 -0.150789525 [56] -0.157708922 -0.164401036 -0.170699667 -0.174828252 -0.177496951 [61] -0.180828834 > (mypacf <- c(rpacf$acf)) [1] 0.9519486937 -0.0827423226 -0.0387161454 -0.0344126958 0.0003505311 [6] -0.0048024377 -0.0293209449 -0.0067735067 0.0518050281 -0.0366096449 [11] -0.0359226034 -0.0390583054 -0.0485025410 -0.0544432509 0.0225106397 [16] 0.0883620087 0.0617173467 -0.0091570063 -0.0173022712 0.0010022364 [21] 0.0351475287 0.0159919567 -0.0112252862 -0.0113185494 -0.0163772709 [26] -0.0196376948 -0.0203297639 -0.0142262039 0.0122278620 -0.0067014282 [31] -0.0005874707 0.0039207413 -0.0007379679 -0.0204630521 -0.0194012525 [36] 0.0018014220 -0.0086022024 -0.0255761327 -0.0116593273 -0.0012864237 [41] -0.0198706529 -0.0232754859 -0.0162422238 -0.0127479793 0.0178077441 [46] -0.0024900736 -0.0100694374 -0.0062587781 -0.0133604971 -0.0172052994 [51] -0.0213008249 -0.0065233040 0.0073223167 -0.0234442347 -0.0141086122 [56] -0.0133547045 -0.0139455469 0.0016971190 -0.0004628184 -0.0111310850 > 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/4faxh1425508003.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/5d7l71425508003.tab") > > try(system("convert tmp/1pnof1425508003.ps tmp/1pnof1425508003.png",intern=TRUE)) character(0) > try(system("convert tmp/24elz1425508003.ps tmp/24elz1425508003.png",intern=TRUE)) character(0) > try(system("convert tmp/3igj71425508003.ps tmp/3igj71425508003.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.205 0.192 1.407