R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(102.89,102.64,103.33,103.56,103.6,104.24,105.31,105.4,105.89,105.89,105.54,106.15,106.14,105.85,106.27,106.51,106.82,106.53,107.14,107.39,107.33,107.53,107.42,108.25,108.26,108.93,109.43,109.61,109.74,110.12,110.16,110.44,111.23,112.86,112.77,113.04,112.79,113.87,114.28,115.51,116.76,116.91,116.47,116.94,117.24,116.82,117.48,117.11,117.31,117.77,118.37,117.91,118.12,118.02,117.77,117.85,118.68,118.9,118.6,118.21,118.37,117.43,117.5,116.71,116.98,117.74,117.44,117.85,118.54,118.73,118.68,118.19) > 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/fisher/rcomp/tmp/1nenx1358204516.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/fisher/rcomp/tmp/26pxd1358204516.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/fisher/rcomp/tmp/31aob1358204516.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.966413304 0.928591336 0.891731189 0.854486820 [6] 0.817515574 0.783725100 0.751625249 0.719647032 0.688679837 [11] 0.653814732 0.615376259 0.575962856 0.534860752 0.490031002 [16] 0.445148032 0.400880798 0.358475625 0.312587584 0.267525668 [21] 0.221618844 0.175826979 0.128451893 0.082337384 0.040227144 [26] -0.001995483 -0.044051828 -0.082472545 -0.122982999 -0.162844236 [31] -0.200737635 -0.240046746 -0.278909643 -0.312157013 -0.335559922 [36] -0.359130685 -0.380241841 -0.403049525 -0.420994859 -0.437646916 [41] -0.444309734 -0.442912701 -0.440932437 -0.441427477 -0.438524362 [46] -0.434884526 -0.432311551 -0.425639531 -0.418701667 > (mypacf <- c(rpacf$acf)) [1] 0.966413304 -0.081206924 -0.001032151 -0.027402032 -0.014796603 [6] 0.027372539 0.000974905 -0.017974330 -0.003353720 -0.080008437 [11] -0.065702213 -0.032793814 -0.049785180 -0.079828173 -0.030353559 [16] -0.030981554 -0.006676746 -0.094298271 -0.020564182 -0.052178962 [21] -0.032031210 -0.063171085 -0.016479283 0.019777648 -0.047537650 [26] -0.041456070 0.018035292 -0.078127128 -0.023256805 -0.017663209 [31] -0.062349261 -0.033489465 0.029047112 0.094031015 -0.043476261 [36] -0.009294517 -0.074183791 0.051418549 -0.013658321 0.131535092 [41] 0.093731919 -0.017407787 -0.075877896 0.027547127 -0.004203469 [46] -0.026525000 0.038413414 -0.022376880 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4rf5q1358204516.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/fisher/rcomp/tmp/5wa0w1358204516.tab") > > try(system("convert tmp/1nenx1358204516.ps tmp/1nenx1358204516.png",intern=TRUE)) character(0) > try(system("convert tmp/26pxd1358204516.ps tmp/26pxd1358204516.png",intern=TRUE)) character(0) > try(system("convert tmp/31aob1358204516.ps tmp/31aob1358204516.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.768 0.540 2.296