R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 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(85,82,92.4,100.3,105.2,104.5,105.1,105,106.5,106,99.4,107.4,89.6,85.3,96.3,107.7,112.7,110.1,110.4,111.6,113.3,109,106.5,113,95.6,93.8,106.4,116.6,119.1,120.9,117.3,117.6,115.3,112.3,107.7,113.4,94.3,97.8,106.6,113,122.4,114.6,115,118.7,110.4,111.6,105.1,107.5,92.9,91,100.2,112.2,116.5,111.2,113.3,112.2,102.2,105.3,96,101.3,86.2,84.4,93.4,104.8,106.2,101.9,105.5,106.4,103.9,108.6,96.4,102.2,90.3,88.5,100.2,111.6,111.5,112.9,110.7,105.5,110.7,108.9,101.3,109.6,94.4,91.4,105.8,112.9,116.1,113.7,112.9,110.7,114.3,109.7,105.7,114) > 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/1p5rz1394716632.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/2xg5t1394716632.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/3pbea1394716632.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.042935452 -0.106272439 -0.095130256 -0.126503280 [6] -0.011442505 -0.133325211 -0.081262595 -0.043045910 -0.085729550 [11] -0.150423070 0.062912643 0.775123852 -0.054507371 -0.024538331 [16] -0.146845834 -0.102792000 0.024528840 -0.185644163 -0.052154396 [21] 0.003852583 -0.127603225 -0.072574386 0.086632625 0.600166970 [26] -0.018707354 -0.024422901 -0.185769859 -0.047474740 0.053447170 [31] -0.227586928 0.001096472 -0.018666683 -0.144712832 -0.000597449 [36] 0.053591429 0.442127276 0.060849736 -0.080281205 -0.172532134 [41] 0.025139651 -0.037252757 -0.160152137 0.058484680 -0.083120260 [46] -0.075752460 0.028034990 -0.019014289 0.380111128 > (mypacf <- c(rpacf$acf)) [1] -0.042935452 -0.108315567 -0.106278425 -0.152503013 -0.054795028 [6] -0.191898550 -0.161089605 -0.160873242 -0.232947293 -0.394304676 [11] -0.303518194 0.681725415 0.039163479 0.085109554 -0.043520439 [16] 0.099944002 -0.011048371 -0.087476514 0.065470028 0.018069132 [21] -0.100641052 0.140395686 -0.006664061 0.028578840 0.006144484 [26] -0.003294180 -0.072024924 -0.007584687 0.144761774 -0.062523413 [31] 0.018235123 -0.005481372 -0.053383952 -0.030973579 -0.054292679 [36] -0.174215347 0.052957194 -0.117129040 -0.006614468 0.005973467 [41] -0.211764438 0.042830139 0.031791965 -0.073903456 0.028928566 [46] 0.018435476 -0.044467211 -0.079631665 > 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/46f0i1394716632.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/5a72d1394716632.tab") > > try(system("convert tmp/1p5rz1394716632.ps tmp/1p5rz1394716632.png",intern=TRUE)) character(0) > try(system("convert tmp/2xg5t1394716632.ps tmp/2xg5t1394716632.png",intern=TRUE)) character(0) > try(system("convert tmp/3pbea1394716632.ps tmp/3pbea1394716632.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.102 0.375 2.481