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(1060,1050,1025,1085,1160,1310,1445,1445,1615,1650,1255,1175,1300,1280,1390,1340,1110,1325,1265,1150,1430,1655,1570,1345,1430,1260,1495,1125,895,1085,870,1185,1455,1540,1615,1200,1260,1095,1160,1095,1300,1215,1245,1350,1300,1280,1270,1065,1340,1265,1155,930,880,925,980,1015,1040,1365,1160,1115,1630,1225,1200,1265,1140,1270,1445,1305,1665,1830,1690,1520) > 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/1aela1413629894.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/2r94i1413629894.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/3szs71413629894.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.599071881 0.346262366 0.167377619 -0.105328180 [6] -0.132635378 -0.148258473 -0.150069151 -0.022040508 0.045260649 [11] 0.020070952 0.097470357 0.148639147 -0.010944552 -0.020264461 [16] -0.122917467 -0.147083670 -0.142843359 -0.239415094 -0.225550214 [21] -0.186296959 -0.205920162 -0.117824676 0.009857035 0.099325111 [26] 0.156527587 0.188826616 0.119239491 0.071561897 -0.121396549 [31] -0.265707858 -0.233024261 -0.256986718 -0.154830511 0.025780055 [36] 0.102415517 0.156692426 0.096164914 -0.063006532 -0.079355937 [41] -0.124653019 -0.200497044 -0.121265644 -0.085054322 -0.073429796 [46] -0.007961498 0.002745949 0.047191946 0.131958696 > (mypacf <- c(rpacf$acf)) [1] 0.5990718807 -0.0196919341 -0.0504730281 -0.2831964427 0.0935953538 [6] -0.0418517157 -0.0088254706 0.0840979770 0.0381366827 -0.1025792255 [11] 0.1063541770 0.1141328385 -0.2451975208 0.0395005547 -0.1110001006 [16] 0.1027457217 -0.1823452799 -0.1044977153 -0.0635055665 -0.0479601710 [21] -0.1168479175 0.0689226553 0.0783790199 0.0329776779 0.0239631987 [26] 0.0678573865 0.0134287817 -0.0926824260 -0.2081247003 -0.0561186021 [31] 0.0342503909 -0.1477426143 0.0511676569 0.0820778018 -0.0178286773 [36] -0.1497177533 -0.0814432921 -0.1627278611 0.0397152694 -0.1264711311 [41] 0.0561535867 0.0062173722 -0.0538280246 -0.0487625245 -0.0184073652 [46] -0.0003713575 -0.0579379785 0.0674651766 > 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/48vvg1413629894.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/5w67j1413629894.tab") > > try(system("convert tmp/1aela1413629894.ps tmp/1aela1413629894.png",intern=TRUE)) character(0) > try(system("convert tmp/2r94i1413629894.ps tmp/2r94i1413629894.png",intern=TRUE)) character(0) > try(system("convert tmp/3szs71413629894.ps tmp/3szs71413629894.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.165 0.182 1.358