R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(10700,12400,12000,12800,11800,11900,11900,12300,11700,11900,11900,14000,11300,12600,12600,12600,11300,12200,11800,12800,11400,11600,11700,14100,11000,12800,13300,12600,10700,12600,12700,14100,11600,11300,11600,13000,10800,13800,12600,12500,9900,11800,12400,15000,11500,11100,10800,12700,10500,14900,12800,12300,9600,11000,12700,15300,12900,11200,11000,13100,10200,15100,12600,11600,9700,10200,12100,15300,13500,10700,11400,12500,9300,15100,12300,11800,9600,9600,12400,16400,13500,11000,11200,12900,8900,15600,12500,11700,9000,8600,13100,16100,14400,11300,12200,14000,9300,14900,12500,11600,9100,8800,13000,15500,14600,11200,12700,14100) > 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/1j32w1405421696.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/23toe1405421696.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/30kao1405421696.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.0000000000 0.0416299681 -0.2281250407 -0.4371127021 -0.0509651130 [6] 0.0597285242 0.3362192982 0.0362602478 -0.0465010440 -0.3946051743 [11] -0.2281332501 -0.0181949910 0.8431333615 0.0502399917 -0.1776362784 [16] -0.3840425951 -0.0457131464 0.0415341233 0.3078251224 0.0375427620 [21] 0.0013694313 -0.3332562932 -0.2102534746 -0.0531787533 0.6480794457 [26] 0.0434275198 -0.1159724640 -0.3061130768 -0.0341218774 0.0148429885 [31] 0.2368669279 0.0231829740 0.0460351603 -0.2458529166 -0.1777103683 [36] -0.0695712926 0.4879009281 0.0237277193 -0.0619390860 -0.2461633860 [41] -0.0198485960 -0.0004846884 0.1673827320 0.0063111081 0.0837917516 [46] -0.1566088889 -0.1461914879 -0.0688216713 0.3362357684 > (mypacf <- c(rpacf$acf)) [1] 0.0416299681 -0.2302571431 -0.4398875976 -0.1336901943 -0.1937410575 [6] 0.1185857787 -0.0374013181 0.0368118893 -0.2800985673 -0.3589637518 [11] -0.3918721469 0.6859643000 -0.2080154234 0.0708536906 0.1787477905 [16] -0.0383777339 -0.0790195635 -0.0263524825 0.0207971686 0.0496266033 [21] -0.0009875354 0.0637154467 0.0796919627 -0.2678461997 0.0153231066 [26] 0.0275374708 -0.0514316219 0.0066486541 0.0389787385 -0.1070934942 [31] -0.0615962609 -0.0611661966 0.0362520640 -0.0468969724 -0.0245359555 [36] 0.0801931560 -0.0762372470 -0.0420727807 -0.0676204015 -0.0212703997 [41] -0.0376446716 -0.0471521129 0.0164960641 0.0454366372 -0.0290711589 [46] -0.0325127294 0.0623259982 -0.1673555254 > 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/40j2a1405421696.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/5s0ko1405421696.tab") > > try(system("convert tmp/1j32w1405421696.ps tmp/1j32w1405421696.png",intern=TRUE)) character(0) > try(system("convert tmp/23toe1405421696.ps tmp/23toe1405421696.png",intern=TRUE)) character(0) > try(system("convert tmp/30kao1405421696.ps tmp/30kao1405421696.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.136 0.206 1.346