R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(31.5,31.29,31.3,31.06,31.09,31.11,31.13,31.1,31.03,30.74,30.83,30.82,30.8,30.74,30.71,30.58,30.71,30.7,30.7,30.72,30.68,30.78,30.84,30.8,30.8,30.88,30.87,30.92,30.82,30.75,30.75,30.75,30.63,30.52,30.58,30.6,30.6,30.63,30.56,30.61,30.53,30.6,30.6,30.63,30.66,30.34,30.32,30.3,30.3,30.08,29.96,29.91,29.83,29.89,29.85,30.06,29.83,29.95,30.02,30.03,30.03,29.96,29.85,30.12,29.91,29.9,29.92,29.89,29.96,29.72,29.6,29.54,29.54,29.54,29.48,29.55,29.58,29.6,29.6,29.56,29.7,29.76,29.24,29.28) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1ouze1386008986.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/2akic1386008986.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/3rrgc1386008986.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.2281260561 0.0003465950 -0.0186840828 -0.0013581588 [6] 0.1226279798 -0.0268204191 -0.1729729918 0.0588197359 -0.0761556867 [11] -0.0828507149 -0.0334902409 0.0101681229 0.0722842163 -0.0720892715 [16] -0.0176704207 -0.0443531474 0.0879905013 0.0319528748 -0.0947444021 [21] 0.1289211927 0.0342187836 -0.0154399310 -0.0241984330 -0.0203699650 [26] -0.0579928509 0.0544292362 -0.1614515575 -0.0411327146 -0.0472258962 [31] -0.0249441076 -0.0343860252 0.0593303187 0.0624996215 -0.0349463701 [36] -0.1338154091 0.1064219090 0.2182377405 -0.0265041303 -0.0037174961 [41] -0.0778953948 0.0674904670 0.0978508880 -0.0694743374 0.0353927017 [46] -0.0437399593 -0.0404538144 0.0780407500 -0.1200480930 0.0677194497 [51] 0.0181224630 0.0001576929 -0.0716304562 0.1050172551 -0.0926416976 [56] 0.0448121354 0.0095073507 -0.0619115336 0.0123594350 0.0241408753 [61] -0.0558350323 > (mypacf <- c(rpacf$acf)) [1] -0.2281260561 -0.0545328750 -0.0328428509 -0.0141476261 0.1249035146 [6] 0.0329507827 -0.1772278143 -0.0207896768 -0.0835167549 -0.1561523499 [11] -0.0967714377 0.0159602547 0.0726248933 -0.0537099116 -0.0142418303 [16] -0.0840462799 -0.0009678122 0.0116211929 -0.0908384271 0.1088005148 [21] 0.0863853178 0.0034577988 -0.0473950527 -0.0133149212 -0.1420646683 [26] -0.0550312631 -0.1112628371 -0.1028392202 -0.0949499819 -0.0597348416 [31] -0.0701186653 0.0285478207 0.0848425700 -0.0681551707 -0.2481828223 [36] -0.0207011975 0.2054976717 -0.0071537694 0.0128823484 -0.0081750762 [41] -0.0457376350 0.0055797433 -0.0309267565 0.0486254460 -0.0279684812 [46] -0.0540563559 0.1433409108 0.0162488830 0.0235741525 -0.0411011060 [51] 0.0536582033 -0.0923476175 0.0830819029 -0.1428941818 -0.0482764573 [56] 0.0620882549 -0.1174375430 -0.0941325659 -0.0233298998 -0.0196797074 > 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/4r0tr1386008986.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/5g16d1386008986.tab") > > try(system("convert tmp/1ouze1386008986.ps tmp/1ouze1386008986.png",intern=TRUE)) character(0) > try(system("convert tmp/2akic1386008986.ps tmp/2akic1386008986.png",intern=TRUE)) character(0) > try(system("convert tmp/3rrgc1386008986.ps tmp/3rrgc1386008986.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.784 0.574 3.326