R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(227.81,227.81,227.01,227.26,227.1,227.59,227.59,227.7,227.75,226.33,225.95,226.33,226.33,226.22,224.84,221.88,222.37,221.8,221.8,221.8,221.9,220.2,219.95,220.05,220.05,220.05,220.62,221.53,221.61,221.5,221.5,221.87,222.27,220.86,221.49,221.67,221.67,221.72,221.67,220.29,220.75,219.59,219.59,219.59,219.82,221.59,220.9,221.01,221.01,219.69,221,219.82,218.04,217.97,217.97,217.53,217,217.18,217.68,217.71) > 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/1afhn1337868099.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/2wtky1337868099.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/3ewow1337868099.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.00000000 0.92429479 0.84948691 0.77806195 0.69637051 0.62630644 [7] 0.54723765 0.46295036 0.37981261 0.30163848 0.25293656 0.19760619 [13] 0.15070348 0.10692793 0.05532131 0.02433366 0.01006843 -0.01319776 [19] -0.02076584 -0.03906368 -0.05392461 -0.07318033 -0.06338223 -0.04936429 [25] -0.03637967 -0.02857527 -0.01618188 -0.01649252 -0.01939230 -0.02491088 [31] -0.02980754 -0.02992532 -0.03978352 -0.05834299 -0.06718014 -0.09636226 [37] -0.12455707 -0.14830167 -0.18738183 -0.22734368 -0.24535003 -0.27320020 [43] -0.28842523 -0.30897323 -0.32430780 -0.34352193 -0.35922650 -0.35769776 [49] -0.35907346 > (mypacf <- c(rpacf$acf)) [1] 0.924294786 -0.033182106 -0.017167022 -0.110529219 0.032392285 [6] -0.108755509 -0.079234133 -0.063499503 -0.012699273 0.144463372 [11] -0.089024085 0.022288887 -0.047304872 -0.066770918 0.058952460 [16] 0.073916290 -0.086408973 0.070163341 -0.075112663 -0.001919058 [21] -0.088430488 0.200836234 -0.025360540 0.064184550 -0.077099667 [26] 0.051480050 -0.098154752 -0.068097929 -0.043613711 0.035956602 [31] 0.081123971 -0.090178984 -0.035327323 0.010348488 -0.155305471 [36] -0.044374169 0.045860570 -0.159122779 0.007058852 0.112819756 [41] -0.107181298 -0.020578943 -0.018222925 -0.043633720 -0.043963089 [46] -0.013130680 0.031708057 -0.023983264 > 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/41l421337868099.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/5gq071337868099.tab") > > try(system("convert tmp/1afhn1337868099.ps tmp/1afhn1337868099.png",intern=TRUE)) character(0) > try(system("convert tmp/2wtky1337868099.ps tmp/2wtky1337868099.png",intern=TRUE)) character(0) > try(system("convert tmp/3ewow1337868099.ps tmp/3ewow1337868099.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.134 0.273 1.438