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(655362,873127,1107897,1555964,1671159,1493308,2957796,2638691,1305669,1280496,921900,867888,652586,913831,1108544,1555827,1699283,1509458,3268975,2425016,1312703,1365498,934453,775019,651142,843192,1146766,1652601,1465906,1652734,2922334,2702805,1458956,1410363,1019279,936574,708917,885295,1099663,1576220,1487870,1488635,2882530,2677026,1404398,1344370,936865,872705,628151,953712,1160384,1400618,1661511,1495347,2918786,2775677,1407026,1370199,964526,850851,683118,847224,1073256,1514326,1503734,1507712,2865698,2788128,1391596,1366378,946295,859626) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '1' > 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/fisher/rcomp/tmp/153o91386160397.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/fisher/rcomp/tmp/244l21386160397.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/fisher/rcomp/tmp/31w9r1386160397.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.000000e+00 -3.166481e-01 1.903176e-01 8.747929e-02 -2.932563e-02 [6] 7.620049e-02 -7.191902e-02 -1.764528e-01 -5.234527e-02 -4.345873e-02 [11] -2.293433e-01 1.805673e-01 -4.266669e-01 1.128046e-01 -2.853430e-03 [16] -1.001214e-02 1.263418e-02 6.757008e-02 1.702227e-01 3.282411e-02 [21] 3.203348e-02 1.360642e-01 -4.076396e-02 1.555221e-01 -8.288086e-02 [26] -1.386421e-02 7.818742e-03 -9.057782e-02 9.220450e-03 -4.317972e-02 [31] -1.974041e-01 6.405615e-02 7.036630e-02 -2.221025e-01 1.854050e-01 [36] -1.368962e-01 1.052304e-01 7.978154e-03 4.153867e-03 3.121926e-02 [41] 4.908741e-03 -1.375745e-02 7.482684e-02 -3.444568e-02 -7.222102e-02 [46] 8.968640e-02 -7.362931e-02 2.572777e-02 -4.091169e-02 2.840196e-03 [51] 1.153577e-04 -5.389560e-03 -9.905288e-03 6.132930e-05 3.755885e-04 [56] -5.980291e-04 -1.782076e-04 -1.018725e-03 5.551934e-04 -3.620793e-05 > (mypacf <- c(rpacf$acf)) [1] -0.316648088 0.100086848 0.194677893 0.034242915 0.030075013 [6] -0.070430173 -0.272882885 -0.222209683 -0.037029966 -0.184094277 [11] 0.150914339 -0.295595915 -0.176761145 -0.025234622 0.066028363 [16] -0.051199263 0.024827524 0.206611209 -0.024439106 -0.196181063 [21] 0.125377225 -0.131383759 0.244203716 -0.070410683 -0.027724514 [26] 0.005305070 -0.003510558 0.025104817 0.053877429 -0.027506270 [31] 0.054997007 0.036323784 -0.015275403 -0.074449977 0.088937042 [36] -0.039483346 -0.082713375 0.052888444 -0.031660477 -0.104061828 [41] -0.043038689 -0.012984547 -0.012959871 -0.030404927 -0.006173431 [46] -0.088201245 0.028428362 0.032264700 -0.133265485 0.017254660 [51] 0.049158475 -0.090021908 -0.039830165 0.023193789 -0.058577750 [56] -0.002544824 -0.013453873 0.028274568 -0.016511772 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4zjzw1386160397.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/fisher/rcomp/tmp/5mk051386160397.tab") > > try(system("convert tmp/153o91386160397.ps tmp/153o91386160397.png",intern=TRUE)) character(0) > try(system("convert tmp/244l21386160397.ps tmp/244l21386160397.png",intern=TRUE)) character(0) > try(system("convert tmp/31w9r1386160397.ps tmp/31w9r1386160397.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.848 0.803 3.595