R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-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(449,446,447,451,465,460,433,431,437,442,449,450,435,431,434,439,455,452,426,428,433,438,442,446,442,436,444,454,469,471,443,437,444,451,457,460,454,439,441,446,459,456,433,424,430,428,424,419,409,397,397,401,413,413,390,385,397,398,406,412,409,404,412,418,434,431,406,416,424,427,438,444,442,443,453,471,476,476,461,462,460,463,467,468) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1otag1395070343.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/2mqvn1395070343.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/3x5l01395070343.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.00000000 0.21941105 -0.39278909 -0.32230695 -0.17859483 0.20826728 [7] 0.48218542 0.21335358 -0.16979955 -0.35620992 -0.37884992 0.18367008 [13] 0.73885067 0.12875609 -0.38650934 -0.30128391 -0.17377739 0.14662417 [19] 0.33406651 0.16364928 -0.19465917 -0.37216085 -0.34033479 0.13611969 [25] 0.55853155 0.10745409 -0.34475894 -0.28559728 -0.16493931 0.11444272 [31] 0.26053587 0.14750347 -0.13679695 -0.26090952 -0.21927804 0.14324342 [37] 0.44889729 0.07874527 -0.25758305 -0.16592959 -0.08039793 0.11262993 [43] 0.22043184 0.10467849 -0.11553067 -0.18805785 -0.14251417 0.09078886 [49] 0.35728260 > (mypacf <- c(rpacf$acf)) [1] 2.194110e-01 -4.632308e-01 -1.264896e-01 -3.157115e-01 1.825758e-01 [6] 2.570681e-01 2.027444e-01 1.181889e-01 -8.052418e-02 -3.678127e-01 [11] 9.860100e-02 4.727017e-01 -2.246107e-01 -4.791079e-02 2.100148e-03 [16] 1.192100e-02 -7.393286e-02 -2.420724e-01 3.931330e-02 -1.610502e-01 [21] -1.222515e-02 -1.253285e-01 -6.329837e-02 1.726595e-02 5.710678e-02 [26] -1.757262e-02 -4.880064e-02 -5.373355e-02 2.738955e-02 -1.133253e-01 [31] -5.808128e-02 1.773964e-03 2.138360e-01 7.768616e-02 9.626598e-02 [36] -1.141053e-02 -2.159058e-02 -1.427189e-05 3.799726e-02 -9.351993e-02 [41] -4.169751e-02 2.977730e-03 2.712847e-03 -1.078070e-01 -2.689623e-02 [46] -4.998872e-02 -1.055878e-01 -8.480347e-05 > 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/40m0c1395070344.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/5nuaz1395070344.tab") > > try(system("convert tmp/1otag1395070343.ps tmp/1otag1395070343.png",intern=TRUE)) character(0) > try(system("convert tmp/2mqvn1395070343.ps tmp/2mqvn1395070343.png",intern=TRUE)) character(0) > try(system("convert tmp/3x5l01395070343.ps tmp/3x5l01395070343.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.859 0.635 3.489