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(1196,1141,6081,-3508,1782,-891,-2043,35,5042,-1837,406,-3621,1987,1627,6692,-3999,679,-215,-2820,799,9957,5154,1302,6287,1891,2191,7336,-2351,881,388,-1936,1120,4438,-3495,1012,-3704,2879,1907,6451,-2814,1613,-40,-3086,292,5283,-1671,3529,-3191,2090,3278,5686,-1817,2322,-705,-1980,646,6077,2632,2356,-1717,1733,2232,6167,-4668,1694,589,-4163,174,5421,-38,3158,-4322,1920,2527,7755,-2567,-388,-2084,-2024,-131,5615,187,2054,-7172) > 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/1dsq11419508727.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/2zufe1419508727.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/3hz5k1419508727.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.149633531 0.022927653 -0.188648827 -0.002071795 [6] -0.151776153 0.457354205 -0.167173431 0.052528399 -0.247824326 [11] -0.082104117 -0.190398709 0.589756097 -0.165530581 -0.076046165 [16] -0.182972389 -0.031585543 -0.113142743 0.347925211 -0.158887180 [21] 0.049149600 -0.176466952 -0.061664096 -0.117511350 0.514336486 [26] -0.138085404 0.018478155 -0.188572219 -0.008515248 -0.061861233 [31] 0.318291913 -0.146602087 0.103890823 -0.169941016 -0.024881474 [36] -0.119735085 0.466408154 -0.104256116 0.055020093 -0.138475518 [41] -0.085421458 -0.049852777 0.233392108 -0.141353593 0.115031403 [46] -0.153227011 -0.083477151 -0.081522584 0.309053835 > (mypacf <- c(rpacf$acf)) [1] -0.1496335311 0.0005497684 -0.1893779688 -0.0614985580 -0.1728685789 [6] 0.4049941479 -0.0973167481 -0.0049858241 -0.1693255391 -0.1697334679 [11] -0.1693670716 0.4354248191 -0.0678141661 -0.2934275552 -0.0384043650 [16] 0.0208724439 0.0321515258 -0.1183996326 -0.1158780457 -0.0242747024 [21] 0.0146061083 0.0017697606 -0.0886856984 0.1502023551 -0.0563051989 [26] 0.0747205166 -0.1259460524 -0.0555410469 0.0313974276 -0.0113282775 [31] -0.0211292088 -0.0371221235 0.0237471505 0.0389957944 -0.0269916076 [36] 0.1072158610 0.0366339990 0.0370399141 0.0660546803 -0.1477799792 [41] -0.0024341775 -0.0664861052 0.0406166056 0.0020604945 -0.0405682960 [46] -0.0135032502 0.0511644307 0.0212853339 > 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/4hdcm1419508727.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/5ng8g1419508727.tab") > > try(system("convert tmp/1dsq11419508727.ps tmp/1dsq11419508727.png",intern=TRUE)) character(0) > try(system("convert tmp/2zufe1419508727.ps tmp/2zufe1419508727.png",intern=TRUE)) character(0) > try(system("convert tmp/3hz5k1419508727.ps tmp/3hz5k1419508727.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.242 0.209 1.456