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(9769,9321,9939,9336,10195,9464,10010,10213,9563,9890,9305,9391,9928,8686,9843,9627,10074,9503,10119,10000,9313,9866,9172,9241,9659,8904,9755,9080,9435,8971,10063,9793,9454,9759,8820,9403,9676,8642,9402,9610,9294,9448,10319,9548,9801,9596,8923,9746,9829,9125,9782,9441,9162,9915,10444,10209,9985,9842,9429,10132,9849,9172,10313,9819,9955,10048,10082,10541,10208,10233,9439,9963,10158,9225,10474,9757,10490,10281,10444,10640,10695,10786,9832,9747,10411,9511,10402,9701,10540,10112,10915,11183,10384,10834,9886,10216) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '2' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '2' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'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/18qre1354365248.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/2eemq1354365248.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/3dfvv1354365248.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.294593779 -0.195341450 -0.050544680 -0.059135303 [6] 0.182463418 -0.010421808 -0.111963391 -0.027179122 0.208172244 [11] -0.020780726 0.048649060 -0.376304723 0.019088686 0.343745303 [16] -0.142746792 0.013676032 -0.058550515 0.109402112 0.036033593 [21] -0.096440901 -0.099034861 -0.027990768 0.257706148 -0.057423262 [26] 0.034562751 -0.231753867 0.125232679 0.079696522 -0.080684670 [31] -0.025548934 -0.123394355 0.168160710 0.092097966 -0.054208783 [36] -0.142842619 0.014911749 0.014481108 0.070515364 0.046005531 [41] -0.159846106 0.118956244 -0.017233224 0.032698858 -0.048125010 [46] -0.065929935 0.058544724 0.028230414 -0.026122303 -0.008610707 [51] 0.024062032 -0.050320175 0.079813760 -0.077179984 -0.057393459 [56] 0.070074701 0.040844417 -0.002273135 -0.067063343 0.046453571 [61] 0.023559977 > (mypacf <- c(rpacf$acf)) [1] -0.294593779 -0.308938308 -0.262549978 -0.312302602 -0.070528301 [6] -0.074881055 -0.148723278 -0.169632402 0.129162001 0.095876485 [11] 0.269741776 -0.225805947 -0.223046978 0.043697427 -0.167662374 [16] -0.133405395 -0.069441112 0.172510238 0.129822160 0.020678318 [21] 0.083076020 -0.031212637 0.191996467 -0.091000484 0.004879228 [26] -0.077428436 0.018070365 -0.039559721 -0.001607103 0.091671548 [31] -0.076967472 -0.134162183 0.030323822 -0.051427937 0.035662333 [36] -0.065924136 -0.128040553 -0.056445719 0.040417857 -0.027696847 [41] -0.056464835 -0.037549666 -0.007309873 -0.066483852 0.085235171 [46] -0.039163839 0.022767326 -0.128860221 -0.006096422 -0.070550168 [51] -0.026450268 -0.011025488 -0.054965803 -0.029755839 -0.036283353 [56] -0.013220870 -0.028117221 -0.110399446 0.071118394 0.028140753 > 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/41yju1354365248.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/55tlo1354365248.tab") > > try(system("convert tmp/18qre1354365248.ps tmp/18qre1354365248.png",intern=TRUE)) character(0) > try(system("convert tmp/2eemq1354365248.ps tmp/2eemq1354365248.png",intern=TRUE)) character(0) > try(system("convert tmp/3dfvv1354365248.ps tmp/3dfvv1354365248.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.974 0.516 2.471