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(1329,1385,1681,1591,1598,1557,1190,932,1664,1717,1567,1355,1430,1863,1868,1711,1873,2095,1379,1021,1999,2094,2026,1390,1744,2117,1823,1963,1816,1966,1309,1250,2184,2295,1870,1222,1640,2194,2179,1976,1850,2077,1658,1156,2400,2218,1802,1444,1804,1541,2206,1972,1815,1749,1492,1307,1916,2035,1855,1086,1951,1733,1868,1532,1894,1586,1247,1212,2119,1931,1649,1296,1625,1454,1562,1612,1648,1412,1219,1207,1614,1537,1497,1141,1135,1368,1203,1201,1190,1347,607,914,1606,1518,1120,910) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '1' > 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/1nmcy1425584700.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/2udra1425584700.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/3owy61425584700.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.346235379 0.231331432 0.460088121 0.501369900 [6] 0.213725965 0.340208410 0.420695363 0.245430139 0.174269222 [11] 0.374523276 0.198397794 -0.034142393 0.175194626 0.284209956 [16] 0.041559109 0.094314398 0.203994119 0.145931339 0.022844883 [21] 0.162364949 0.166990424 0.038551912 0.111829651 0.153903663 [26] 0.119388735 -0.007733566 0.121793043 0.121764940 -0.008169919 [31] 0.001640246 0.111248442 -0.097859759 -0.033441864 -0.012983023 [36] -0.026918146 -0.162268633 -0.015504316 -0.017463362 -0.111400573 [41] -0.154427437 -0.056161104 -0.156099210 -0.177432812 -0.084292871 [46] -0.086428780 -0.150376317 -0.080158792 -0.130025306 > (mypacf <- c(rpacf$acf)) [1] 0.346235379 0.126633140 0.399870470 0.337810656 -0.056326219 [6] 0.148345607 0.084085089 -0.063492427 -0.060396595 0.100548093 [11] -0.138062549 -0.279554067 -0.001653320 0.090794035 0.023888555 [16] 0.162494325 0.041466149 0.102032940 0.032177918 0.025105944 [21] 0.016728102 -0.032387851 -0.016205478 -0.181015208 0.044111531 [26] -0.139178590 -0.010630851 0.063009226 -0.057696214 0.005207465 [31] 0.056268552 -0.203408287 0.084825442 -0.089472510 -0.012223793 [36] -0.086757178 0.104323138 0.023007764 0.018015574 0.058913901 [41] -0.147911515 -0.072369686 -0.087647998 -0.089972727 0.014880723 [46] 0.071332369 0.072331733 -0.082857606 > 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/4n4e11425584700.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/5pnx11425584700.tab") > > try(system("convert tmp/1nmcy1425584700.ps tmp/1nmcy1425584700.png",intern=TRUE)) character(0) > try(system("convert tmp/2udra1425584700.ps tmp/2udra1425584700.png",intern=TRUE)) character(0) > try(system("convert tmp/3owy61425584700.ps tmp/3owy61425584700.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.299 0.282 1.588