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(193590,193745,193885,194040,194190,194345,194495,194650,194805,194955,195110,195260,195415,195570,195710,195865,196015,196170,196320,196475,196630,196780,196935,197085,197240,197395,197540,197695,197845,198000,198150,198305,198460,198610,198765,198915,199070,199225,199365,199520,199670,199825,199975,200130,200285,200435,200590,200740,200895,201050,201190,201345,201495,201650,201800,201955,202110,202260,202415,202565,202720,202875,203015,203170,203320,203475,203625,203780,203935,204085,204240,204390,204545,204700,204845,205000,205150,205305,205455,205610,205765,205915,206070,206220,206375,206530,206670,206825,206975,207130,207280,207435,207590,207740,207895,208045,208200,208355,208495,208650,208800,208955,209105,209260,209415,209565,209720,209870) > 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/1mg5x1439766354.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/2ch481439766354.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/3fn0q1439766354.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.478102446 0.136445212 -0.026310443 -0.105991564 [6] 0.207960856 -0.445348629 0.242439194 -0.141848552 0.013848174 [11] 0.102257116 -0.420488187 0.848821375 -0.421594735 0.123724144 [16] -0.025185755 -0.091021120 0.181394033 -0.388840918 0.215872371 [21] -0.126878108 0.014972862 0.089536048 -0.363980476 0.725334262 [26] -0.365087024 0.103109702 -0.018108686 -0.083944051 0.160779590 [31] -0.340226582 0.181412173 -0.105955283 0.008204176 0.074873987 [36] -0.323259515 0.669134934 -0.324366063 0.096341015 -0.024877373 [41] -0.063021226 0.126319392 -0.291612246 0.160797730 -0.098878214 [46] 0.015281245 0.062152919 -0.266751804 0.559493576 > (mypacf <- c(rpacf$acf)) [1] -0.478102446 -0.119438139 -0.013660724 -0.143833975 0.121779533 [6] -0.387410348 -0.197343863 -0.183073667 -0.186619847 -0.084233467 [11] -0.630089071 0.561206632 0.230166318 -0.088988668 0.011652924 [16] -0.051165772 -0.093635070 0.138947294 -0.107722519 -0.006758931 [21] -0.041125960 -0.085216417 0.019670996 0.021235037 -0.034295854 [26] -0.010907016 -0.061326266 -0.043368487 -0.020172612 -0.039359699 [31] -0.089421650 -0.058871891 -0.085051594 -0.110561941 -0.127503216 [36] 0.112444773 0.040369229 0.012390010 -0.048765963 -0.023199895 [41] -0.057521232 0.036033271 0.023857538 -0.016439332 -0.017824167 [46] 0.024497414 0.107629098 -0.108015528 > 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/4cedr1439766354.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/5ki7e1439766354.tab") > > try(system("convert tmp/1mg5x1439766354.ps tmp/1mg5x1439766354.png",intern=TRUE)) character(0) > try(system("convert tmp/2ch481439766354.ps tmp/2ch481439766354.png",intern=TRUE)) character(0) > try(system("convert tmp/3fn0q1439766354.ps tmp/3fn0q1439766354.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.239 0.182 1.429