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(989,1215,2911,2372,2013,2050,1580,1407,903,709,490,206,1101,1189,2877,2489,2145,1837,1613,1296,849,642,475,224,920,1263,2999,2988,2163,2391,1556,1089,976,626,392,203,1052,1034,2353,3075,2309,2009,1464,1099,1035,792,406,187,862,822,2128,2264,1987,1728,1311,1152,945,704,526,361,1035,869,2698,2367,1926,1843,1404,1314,1007,865,587,339,1143,1807,2380,2337,2117,1789,1569,1305,952,810,473,278,993,1038,2257,2284,1747,1515,1233,882,1029,707,391,239,592,692,2127,1854,1468,1535,1203,880,821,604,315,139,528,654,1895,1598,1519,1242,1027,762,735,485,281,131,651,611,1898,1385,1047,1008,843,833,711,444,315,204,473,566,1611,1301,1154,1158,862,801,559,404,223,158,548,647,1757,1326,1308,1175,992,808,758,553,310,146) > 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/1mwpm1448817503.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=13.888888888889,height=8.3333333333333) > 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/2m8vg1448817503.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=13.888888888889,height=8.3333333333333) > 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/3f1yz1448817503.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=13.888888888889,height=8.3333333333333) > rpacf <- pacf(x,par1,main='Partial Autocorrelation',xlab='lags',ylab='PACF',sub=mysub) > dev.off() null device 1 > (myacf <- c(racf$acf)) [1] 1.00000000 0.05500449 0.13655399 -0.08319559 -0.29452904 -0.18032200 [7] -0.22075307 -0.18397715 -0.27704285 -0.12596378 0.15457219 0.10966537 [13] 0.80502947 0.11300134 0.14280853 -0.09717544 -0.26689637 -0.15960909 [19] -0.19967681 -0.17625982 -0.24883188 -0.11029852 0.12922101 0.10147793 [25] 0.71935941 0.12088129 0.11866239 -0.08274910 -0.23047429 -0.16223317 [31] -0.15037834 -0.17482467 -0.24273786 -0.08310630 0.13205503 0.07691291 [37] 0.63997372 0.10332193 0.11540200 -0.09869813 -0.18758620 -0.12741936 [43] -0.15054187 -0.13936513 -0.21125110 -0.09483731 0.09988703 0.10711209 [49] 0.56889286 > (mypacf <- c(rpacf$acf)) [1] 0.055004491 0.133933713 -0.099140615 -0.312483019 -0.146590710 [6] -0.149279779 -0.218605843 -0.446432071 -0.451459884 -0.236989714 [11] -0.477935036 0.501101888 0.090702600 0.044758506 -0.150840663 [16] -0.080566804 -0.046662938 0.027773352 0.020436785 0.008113479 [21] 0.101195741 -0.011141670 -0.167741328 0.062972397 0.007991874 [26] -0.045778330 -0.040625914 0.041937937 -0.032426009 0.068648090 [31] -0.031424214 -0.090958258 0.036537473 0.120615728 -0.039522682 [36] 0.021072149 -0.062859030 0.005945197 -0.082258858 0.006264497 [41] 0.059734319 0.006891557 0.057067334 0.032229434 -0.042356552 [46] -0.138443453 0.061606373 0.115248885 > 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/4qto71448817503.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/5x7ht1448817503.tab") > > try(system("convert tmp/1mwpm1448817503.ps tmp/1mwpm1448817503.png",intern=TRUE)) character(0) > try(system("convert tmp/2m8vg1448817503.ps tmp/2m8vg1448817503.png",intern=TRUE)) character(0) > try(system("convert tmp/3f1yz1448817503.ps tmp/3f1yz1448817503.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.362 0.249 1.617