R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(246.24,247.57,247.84,248.27,248.3,248.31,248.31,248.38,248.37,248.41,248.68,248.75,248.75,247.95,248.13,247.86,246.23,245.98,245.98,246.27,246.31,246.3,246.67,246.78,246.78,247.91,247.99,248.6,248.68,248.75,248.75,249.03,249.05,249.57,249.35,249.46,249.46,250.82,254.19,255.18,256.68,256.73,256.73,257.39,257.78,258.67,258.71,258.91,258.91,261.38,262.42,262.77,263.24,262.83,262.83,263.09,263.6,265.68,266.08,266.28,266.28,269.14,270.96,272.97,273.13,274.73,274.73,274.59,275.15,275.16,275.38,275.4) > 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/1fxz41352710795.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/2ki0p1352710795.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/3y7w21352710795.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.0000000000 0.3171163223 0.2204695730 -0.0005614304 0.0653694057 [6] 0.1047629813 0.0646343036 0.0752076034 0.0090662644 -0.0873618651 [11] -0.0588860434 0.1958086906 0.2530667647 0.1499861488 0.0251169733 [16] -0.1538110930 0.0213760314 -0.0325565129 0.0780814332 0.0958019338 [21] -0.0343695150 -0.0939461047 -0.1357192850 0.1120802091 0.1439725249 [26] 0.0685637482 -0.0394653649 -0.0691220755 -0.0785965170 -0.1682649715 [31] -0.0323973664 -0.1338301800 -0.0776660214 -0.2229376884 -0.1132431033 [36] -0.0373609713 -0.0094244554 0.0583675861 0.0341428374 -0.0113346846 [41] -0.0270442647 -0.1226738998 -0.0560941495 -0.0315910340 -0.0911811990 [46] -0.1762592689 -0.1204986313 -0.1000779875 -0.0506154944 > (mypacf <- c(rpacf$acf)) [1] 0.3171163223 0.1333131497 -0.1170761675 0.0759444334 0.1060498349 [6] -0.0237044713 0.0368872850 -0.0168895389 -0.1269966424 0.0006869285 [11] 0.2928115259 0.1371933895 -0.0724411253 -0.0323126252 -0.1863119884 [16] 0.0934944599 -0.0099003667 0.0138773135 0.0902451256 -0.0693492695 [21] -0.0518375328 -0.0706688472 0.1409976785 0.0190299695 -0.0836678365 [26] 0.0327943582 -0.0099907402 -0.0490202074 -0.1883560207 -0.0234235777 [31] -0.1207846814 0.0078531943 0.0118199415 0.0159575435 -0.0596399192 [36] -0.0529331606 0.0769314326 0.1054163386 -0.0529934657 0.0473547040 [41] -0.1077149637 -0.0361712840 0.0493475533 -0.0903723611 -0.0728788850 [46] -0.0391436298 0.0170797959 -0.0427753357 > 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/4z89c1352710795.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/5ridv1352710795.tab") > > try(system("convert tmp/1fxz41352710795.ps tmp/1fxz41352710795.png",intern=TRUE)) character(0) > try(system("convert tmp/2ki0p1352710795.ps tmp/2ki0p1352710795.png",intern=TRUE)) character(0) > try(system("convert tmp/3y7w21352710795.ps tmp/3y7w21352710795.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.143 0.445 2.570