R version 3.0.1 (2013-05-16) -- "Good Sport" 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(293544,282672,298980,239184,309852,304416,326160,337032,375084,326160,309852,385956,326160,244620,288108,217440,304416,250056,331596,298980,315288,353340,347904,413136,298980,250056,277236,201132,288108,222876,315288,298980,266364,380520,342468,391392,293544,271800,244620,201132,266364,239184,326160,315288,271800,364212,337032,434880,347904,212004,212004,212004,250056,250056,337032,309852,277236,347904,320724,462060,364212,212004,222876,184824,255492,293544,369648,364212,293544,342468,304416,434880,331596,266364,239184,179388,266364,320724,375084,353340,260928,375084,293544,451188,375084,271800,250056,168516,266364,255492,385956,385956,293544,380520,282672,440316,375084,277236,212004,146772,288108,277236,364212,418572,309852,347904,260928,451188) > 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/1astb1377077616.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/2kdhm1377077616.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/3zxqx1377077616.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.34099026 0.16117122 -0.18722410 -0.33959598 0.37095515 [7] -0.34394957 0.41811068 -0.28759624 -0.18407928 0.13441850 -0.31309345 [13] 0.78955157 -0.25518104 0.19065720 -0.16484408 -0.35056914 0.33773501 [19] -0.30827381 0.37650662 -0.22422802 -0.15781700 0.10351417 -0.27386725 [25] 0.60242437 -0.13876351 0.17684239 -0.13654251 -0.30831234 0.24726300 [31] -0.25777595 0.30535560 -0.15311370 -0.11856407 0.09306592 -0.26340316 [37] 0.50136785 -0.07654881 0.09898497 -0.08370534 -0.25128367 0.19095897 [43] -0.25392886 0.27663020 -0.10162638 -0.07910882 0.08589391 -0.25104265 [49] 0.39428607 > (mypacf <- c(rpacf$acf)) [1] -0.340990263 0.050804075 -0.133570111 -0.514820883 0.179815217 [6] -0.220958197 0.076756226 -0.234548990 -0.434092504 -0.217000293 [11] -0.396936872 0.445035918 0.108652141 0.043625259 -0.004305512 [16] -0.015357294 0.049770608 0.089723593 -0.104653523 -0.051051396 [21] -0.005491383 -0.041121740 0.039510049 -0.115361413 0.072225167 [26] 0.043009008 -0.018900953 0.066735686 -0.040516409 -0.017416444 [31] -0.047432673 -0.044357007 0.014553393 0.080648596 -0.100601093 [36] 0.127453823 0.068868463 -0.162689084 -0.038457603 0.054242415 [41] 0.071862454 -0.132689471 -0.007348424 0.009600314 0.124014402 [46] 0.053238359 -0.053354514 -0.098083669 > 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/4wysr1377077616.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/59i581377077616.tab") > > try(system("convert tmp/1astb1377077616.ps tmp/1astb1377077616.png",intern=TRUE)) character(0) > try(system("convert tmp/2kdhm1377077616.ps tmp/2kdhm1377077616.png",intern=TRUE)) character(0) > try(system("convert tmp/3zxqx1377077616.ps tmp/3zxqx1377077616.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.861 0.447 2.286