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(93.58,95.79,94.77,94.2,96.23,92.3,88.86,86.44,86.21,88.57,90.69,89,86.88,90.65,90.68,89.64,102.62,101.84,92.51,94.29,94.68,96.94,94.03,89.65,84.9,89.07,89.8,93.22,92.23,98.41,96.63,89.8,90,92.13,93.27,90.81,85.42,88.28,88.73,90.18,92.74,96.13,94.85,94.25,96.94,101.22,98.71,95.51,93.91,98.17,97.59,99.64,107.88,108.49,100.25,99.27,101.73,101.25,97.09,94.74,94.53,93.48,96.05,106.22,98.33,99.86,93.78,88.96,83.77,89.46,86.78,88.4) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/wessaorg/rcomp/tmp/1yjai1445588494.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/25c1i1445588494.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/384ae1445588494.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.0000000000 -0.0442478213 -0.2425576312 -0.0666346802 0.0423847174 [6] -0.1688104932 0.0645456159 0.0082827661 0.0057449253 -0.1659593318 [11] -0.0333521045 0.0803347825 0.2276892938 0.1390553892 -0.1187281440 [16] -0.1994108823 0.0057439644 -0.0271910999 0.0951443157 0.0054047250 [21] -0.0258102487 -0.1434185779 -0.0588089632 0.0505971470 0.1611097095 [26] 0.0325586541 -0.0465537089 -0.1632959284 0.0645294805 0.0055032069 [31] 0.0370475182 0.0056993551 -0.0342118261 -0.0079007973 -0.0673444146 [36] 0.0046181805 0.2966189497 -0.0005611517 -0.1631721164 -0.1092470071 [41] 0.0665151341 -0.0602197354 0.0511379407 0.0232383407 0.0471429909 [46] -0.1758162667 0.0508701025 0.0728168935 -0.0099700902 0.0717138515 [51] -0.0097362879 -0.1299645459 0.0046103717 0.0759533938 -0.0391495124 [56] 0.0079443388 0.0044310396 -0.0662283649 -0.0315135324 0.0548260959 [61] 0.0047264607 > (mypacf <- c(rpacf$acf)) [1] -0.0442478213 -0.2449951695 -0.0968273021 -0.0299894700 -0.2239236263 [6] 0.0333468118 -0.0928342975 -0.0143964601 -0.1984600706 -0.1274707274 [11] -0.0161894256 0.1560414896 0.2205086855 -0.0403229327 -0.1136266776 [16] -0.0339414440 -0.0654868114 0.1191873555 -0.0475097733 -0.0177848939 [21] -0.1153558896 -0.0982130365 -0.0270354325 -0.0277505778 -0.0209306189 [26] -0.0646100540 -0.1051774217 0.0923604722 -0.0615990971 -0.0111154813 [31] -0.0865230928 -0.0843640349 0.1539257196 -0.0745151911 0.0241734000 [36] 0.1835254755 -0.0262156959 0.0364169215 -0.1168762139 0.0541685786 [41] -0.1085938930 0.0047851501 0.0097850530 -0.0317974573 -0.0685225127 [46] -0.0512462018 -0.0097845682 -0.1811609169 0.0266783861 0.0113317613 [51] -0.0009671255 0.0499600487 0.0098605644 -0.1042543359 0.0233822643 [56] -0.0508339066 0.0251261994 0.0148304214 -0.0360904925 -0.0773142075 > 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/4dc7a1445588494.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/5utdy1445588494.tab") > > try(system("convert tmp/1yjai1445588494.ps tmp/1yjai1445588494.png",intern=TRUE)) character(0) > try(system("convert tmp/25c1i1445588494.ps tmp/25c1i1445588494.png",intern=TRUE)) character(0) > try(system("convert tmp/384ae1445588494.ps tmp/384ae1445588494.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.209 1.383