R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(173019,173690,172439,171914,171968,169500,173898,172308,171568,164939,161275,160770,162466,160185,154836,154103,150495,142707,149962,149967,144572,143819,141070,144119,145330,143279,139063,139202,133632,134476,141859,140693,138047,138346,140167,146796,152228,155410,159032,160312,157687,160141,167421,167628,164403,163405,163229,171154,173323,172381,168983,165380,161641,161933,172018,168455,164332,161193,157645,161694,163411,161834,159511,156359,154223,151497,160607,159672,155601,154668,153960,157307,165218,165616,162212,159787,157454,156485,165887,166836,163541,163973,164805,167521,174347,173374,172198,171055,168385,167281,177670,177280,174846,174476,174595,178392,185345,183293,181081,177795,173552,170734,179293,178659,175894,174815,173506,175376) > 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.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/1furm1451738921.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/2z0x41451738921.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/3e1lo1451738921.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.000000000 0.127806202 -0.241028676 -0.149826398 -0.182874566 [6] 0.178891455 0.517312603 0.167843223 -0.168493610 -0.215976906 [11] -0.302971206 0.089010009 0.695528430 0.021180060 -0.304465360 [16] -0.210331160 -0.258087499 0.105372207 0.356639355 0.078015443 [21] -0.235309985 -0.314760523 -0.329058065 0.044219108 0.516297753 [26] 0.009836381 -0.292923918 -0.245698552 -0.246329999 0.073512710 [31] 0.290179469 0.116338462 -0.170280903 -0.214913633 -0.193672468 [36] 0.076296365 0.476202852 0.065559566 -0.213059961 -0.124030818 [41] -0.133308578 0.128295545 0.274700409 0.170442293 -0.122468483 [46] -0.141156469 -0.115340019 0.039419224 0.433299294 > (mypacf <- c(rpacf$acf)) [1] 0.127806202 -0.261636787 -0.084601542 -0.231919317 0.199799555 [6] 0.420829737 0.173258284 0.014601356 -0.057025298 -0.302785855 [11] -0.104478563 0.517390926 -0.224682437 -0.188773987 -0.063958397 [16] -0.021128086 -0.016214405 -0.182076459 -0.022557658 -0.095942561 [21] -0.101268388 -0.046893048 -0.093284999 0.043056607 0.053252309 [26] 0.011798195 -0.071177500 0.002837787 -0.053954310 -0.091433487 [31] 0.012523169 0.012708966 0.186244787 0.121700183 -0.016192845 [36] 0.058227353 -0.052121305 -0.040016880 0.017208007 -0.048463472 [41] 0.015996780 -0.104127255 0.070208960 -0.023635696 0.026336123 [46] 0.010123633 -0.129991146 0.063032123 > 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/40xkv1451738921.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/5zsam1451738921.tab") > > try(system("convert tmp/1furm1451738921.ps tmp/1furm1451738921.png",intern=TRUE)) character(0) > try(system("convert tmp/2z0x41451738921.ps tmp/2z0x41451738921.png",intern=TRUE)) character(0) > try(system("convert tmp/3e1lo1451738921.ps tmp/3e1lo1451738921.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.162 0.215 1.384