R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(660,770,792,693,726,814,770,737,792,693,770,847,627,704,792,693,770,770,737,836,957,737,891,891,671,660,803,693,825,847,726,869,979,748,880,946,737,671,759,748,814,836,737,825,979,803,825,1034,814,704,704,825,847,858,704,803,1067,858,792,1155,869,671,583,825,803,957,737,825,1199,913,814,1111,858,704,649,847,715,968,770,869,1254,946,693,1166,924,792,627,869,627,880,869,858,1232,935,660,1155,891,825,605,814,550,825,902,891,1199,902,693,1188) > 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/1fl021376654569.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/2btxo1376654569.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/3dkwp1376654569.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.087223270 -0.057883334 0.276145150 -0.012592283 [6] -0.219201594 -0.067158125 -0.228668867 -0.015115792 0.225480852 [11] -0.053995989 0.016061282 0.815528126 0.108140200 -0.090445433 [16] 0.245868631 0.006890616 -0.225514508 -0.083274691 -0.204303361 [21] -0.051527600 0.181154766 -0.043562766 -0.052671924 0.611143417 [26] 0.148074065 -0.098481157 0.208966985 0.023723267 -0.231307032 [31] -0.099851527 -0.157269315 -0.096542613 0.146411559 -0.020190734 [36] -0.105025630 0.417256213 0.164908687 -0.091291506 0.139772524 [41] 0.013977546 -0.221550909 -0.107086952 -0.111602281 -0.137613300 [46] 0.103231713 -0.000638844 -0.127759439 0.251080808 > (mypacf <- c(rpacf$acf)) [1] 0.0872232695 -0.0659933027 0.2907518962 -0.0821540010 -0.1838304463 [6] -0.1223581179 -0.2472103399 0.1573704100 0.2879220485 0.0165323596 [11] -0.0455938538 0.7579480909 -0.0706818600 -0.0613144270 -0.1286402246 [16] 0.0535604547 -0.0509205487 -0.0449649259 0.0769342993 -0.0872856934 [21] 0.0221414726 -0.0159167408 -0.0355651729 -0.1875426281 0.1438121353 [26] 0.0622532574 0.0182163425 -0.0841385218 -0.0501346531 -0.0226800571 [31] 0.0705307574 0.0030151685 0.0053886755 -0.0168106914 -0.0460422052 [36] -0.1114807137 -0.0128904392 0.0889504463 -0.0837947034 -0.0669350943 [41] -0.0265501015 0.0427546672 0.0033341683 0.0001990597 -0.0250573653 [46] -0.0760868467 0.0228284680 -0.0431832403 > 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/4bzvq1376654569.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/5oa5t1376654569.tab") > > try(system("convert tmp/1fl021376654569.ps tmp/1fl021376654569.png",intern=TRUE)) character(0) > try(system("convert tmp/2btxo1376654569.ps tmp/2btxo1376654569.png",intern=TRUE)) character(0) > try(system("convert tmp/3dkwp1376654569.ps tmp/3dkwp1376654569.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.005 0.453 2.437