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(92.86,94.06,95.51,96.05,96.71,97.91,97.74,97.64,98.55,98.46,99.19,99.18,99.95,100.66,101.12,101.14,100.73,99.92,100.06,100.64,100.89,100.87,100.72,100.72,100.98,100.15,100.13,100.39,99.87,99.93,99.96,99.61,99.57,99.71,99.78,99.92,100.3,100.83,100.84,97.87,97.99,98.03,97.58,97.45,97.47,98.31,98.29,98.13,98.44,98.05,98.32,97.55,97.74,98.01,97.93,99.23,101.03,100.81,100.57,100.1) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/1xbek1457985233.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/2uhic1457985233.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/33qmk1457985233.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.813739683 0.635234983 0.503199277 0.371411050 [6] 0.273482642 0.225034048 0.181276057 0.124759009 0.070960504 [11] 0.004794394 -0.057473741 -0.146955685 -0.212843335 -0.242941250 [16] -0.258121229 -0.256978133 -0.249605321 -0.247176499 -0.254638030 [21] -0.251882694 -0.227959238 -0.219260695 -0.230691838 -0.238672562 [26] -0.228362011 -0.240271272 -0.247780763 -0.227389739 -0.219146193 [31] -0.200261299 -0.172114379 -0.138821717 -0.122681557 -0.110570088 [36] -0.083579060 -0.057926324 -0.018746183 0.057325157 0.160062411 [41] 0.178814494 0.201239914 0.229217693 0.227314150 0.197234144 [46] 0.155094905 0.138026460 0.123840117 0.107601329 > (mypacf <- c(rpacf$acf)) [1] 0.8137396831 -0.0797367607 0.0296447040 -0.0859534634 0.0184516582 [6] 0.0667393825 -0.0174406160 -0.0601073646 -0.0397010183 -0.0799273255 [11] -0.0364644006 -0.1599868083 -0.0280387115 -0.0043045484 -0.0166416683 [16] -0.0079231268 -0.0352031709 -0.0322235511 -0.0425914239 -0.0089018331 [21] 0.0354399269 -0.0706995189 -0.0890304311 -0.0641221909 -0.0079820876 [26] -0.1055656187 -0.0607571278 -0.0012057397 -0.0674396761 -0.0003992335 [31] -0.0326675899 -0.0092381466 -0.0490589033 -0.0352280269 0.0137267866 [36] -0.0346605637 0.0274871925 0.1004475397 0.1134073549 -0.1577805441 [41] 0.0416100928 0.0170917771 -0.0192010448 -0.0823006970 -0.1029079108 [46] 0.0162814034 -0.0137662668 -0.0427890035 > 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/4e8401457985233.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/5hc1p1457985233.tab") > > try(system("convert tmp/1xbek1457985233.ps tmp/1xbek1457985233.png",intern=TRUE)) character(0) > try(system("convert tmp/2uhic1457985233.ps tmp/2uhic1457985233.png",intern=TRUE)) character(0) > try(system("convert tmp/33qmk1457985233.ps tmp/33qmk1457985233.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.152 0.232 1.388