R version 3.2.2 (2015-08-14) -- "Fire Safety" 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(98.85,98.86,98.86,98.89,98.85,98.85,98.85,98.96,98.99,99.21,99.29,99.32,99.32,99.17,99.13,99.12,99.23,99.25,99.25,99.36,99.43,99.57,99.64,99.68,99.68,99.52,99.69,99.7,99.85,99.94,99.94,99.93,100.19,100.57,100.76,100.86,100.86,100.39,100.61,100.67,100.81,100.86,100.86,100.98,101.03,101.37,101.64,101.68,101.68,101.25,101.24,101.11,101.08,101.09,101.09,101.62,101.66,101.96,102.04,102.02,102.02,101.51,101.62,101.83,102.06,102.14,102.14,102.59,102.92,103.31,103.54,103.58,103.58,102.83,102.86,103.03,103.2,103.28,103.28,103.79,103.92,104.26,104.41,104.45,99.92,99.18,99.18,99.35,99.62,99.67,99.72,100.08,100.39,100.77,101.03,101.07,101.29,101.1,101.2,101.15,101.24,101.16,100.81,101.02,101.15,101.06,101.17,101.22) > 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.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/1xe7x1445632696.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/2fx8t1445632696.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/32dte1445632696.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.935928728 0.852834353 0.769087279 0.695924639 [6] 0.632866828 0.579304411 0.532435925 0.493479712 0.466683595 [11] 0.453619666 0.443759596 0.416956011 0.379091587 0.332115893 [16] 0.288569513 0.252710687 0.228440651 0.209129714 0.189306488 [21] 0.175422852 0.171346332 0.171935862 0.173663713 0.162965646 [26] 0.133123707 0.097457924 0.062711884 0.034926475 0.011243327 [31] -0.004202057 -0.016043117 -0.028551316 -0.038009044 -0.045933115 [36] -0.055494314 -0.075637081 -0.105206211 -0.141121713 -0.170742375 [41] -0.192049005 -0.208322185 -0.223208916 -0.235807200 -0.247106841 [46] -0.253945896 -0.255570662 -0.253301641 -0.261709839 > (mypacf <- c(rpacf$acf)) [1] 0.9359287278 -0.1864617248 -0.0285846720 0.0392852112 0.0164378498 [6] 0.0196528299 0.0071072028 0.0291759643 0.0680223339 0.0789151409 [11] -0.0005799264 -0.1365923940 -0.0457670469 -0.0574030162 0.0182314904 [16] 0.0226608377 0.0479299574 0.0015667675 -0.0289083886 0.0295720738 [21] 0.0379939529 0.0016419373 0.0181361978 -0.0763205574 -0.1039664320 [26] -0.0078743213 -0.0115779060 -0.0004059902 -0.0167367290 0.0417594953 [31] -0.0081068526 -0.0486518906 -0.0132197342 -0.0338500939 -0.0139420185 [36] -0.0558317763 -0.0439712077 -0.0467506181 0.0221781215 0.0056514629 [41] -0.0452663161 -0.0312861405 -0.0048527378 -0.0344913887 -0.0072906954 [46] 0.0054906296 0.0250133709 -0.0775952143 > 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/4vmry1445632696.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/502gf1445632696.tab") > > try(system("convert tmp/1xe7x1445632696.ps tmp/1xe7x1445632696.png",intern=TRUE)) character(0) > try(system("convert tmp/2fx8t1445632696.ps tmp/2fx8t1445632696.png",intern=TRUE)) character(0) > try(system("convert tmp/32dte1445632696.ps tmp/32dte1445632696.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.235 0.228 1.472