R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(2201,1239,966,1001,1079,909,1038,817,817,926,555,156,1604,610,635,623,744,939,993,634,858,849,458,109,1538,739,855,834,1004,1355,968,811,1121,960,973,233,1662,894,966,859,946,1156,895,952,1078,689,621,587,1425,1022,1406,776,1105,2244,679,665,704,449,560,229,1158,908,1104,731,989,1308,757,896,917,844,815,401) > 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/12vuw1425419492.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/2p01d1425419492.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/3px9p1425419492.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.4879972880 -0.0025478465 0.0360687120 0.0110382153 [6] 0.1262332660 -0.2159520015 0.0274125292 0.0879189300 0.0233497753 [11] 0.0014440806 -0.4066381762 0.6682895127 -0.3669134921 0.0701223331 [16] -0.0647749855 0.0103970144 0.1970254292 -0.2338088412 0.0107997583 [21] 0.1177138281 -0.0115045141 0.0131253970 -0.3117271729 0.4587197901 [26] -0.2546427822 0.0877951068 -0.1128618750 -0.0019861084 0.1993532605 [31] -0.2128539198 -0.0049767344 0.1257742000 -0.0359690143 0.0009255451 [36] -0.1551401469 0.2499181180 -0.1354866761 0.0758784570 -0.1158935260 [41] -0.0142467383 0.2144404158 -0.2090778528 -0.0006453948 0.1185187580 [46] -0.0568851712 0.0172731740 -0.1041256387 0.0887875844 > (mypacf <- c(rpacf$acf)) [1] -0.4879972880 -0.3159236960 -0.1745902330 -0.0753485608 0.1714150778 [6] -0.0531862287 -0.1455502044 -0.0543602371 0.0684728571 0.1419730346 [11] -0.4674322593 0.3605645227 0.0053088231 0.1175055076 -0.1075738795 [16] -0.0086534261 0.0419601669 -0.0277834611 0.0006661698 0.0491023587 [21] 0.0116663786 -0.0736745437 -0.0182379051 -0.0030880896 0.0084272953 [26] -0.0193491926 -0.0230030794 -0.0636386695 -0.0595020675 -0.0356071578 [31] -0.0398786222 0.0388651842 -0.0247824801 -0.1201991519 0.1218352735 [36] -0.0348106276 0.0492967503 -0.0406883386 0.0269837595 -0.0948198232 [41] 0.0583573469 -0.0211069142 -0.0015048149 0.0053997888 -0.0389421365 [46] 0.0117093566 -0.0353303782 -0.0920292881 > 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/4lezv1425419492.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/57q0o1425419492.tab") > > try(system("convert tmp/12vuw1425419492.ps tmp/12vuw1425419492.png",intern=TRUE)) character(0) > try(system("convert tmp/2p01d1425419492.ps tmp/2p01d1425419492.png",intern=TRUE)) character(0) > try(system("convert tmp/3px9p1425419492.ps tmp/3px9p1425419492.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.259 0.272 1.536