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(239050,238600,236980,236050,234870,233060,231370,230300,228340,226760,223550,221460,220560,220350,219500,218800,218130,217150,216430,215310,213780,213040,211940,212270,212540,213790,214400,215520,216690,217630,218710,219360,219800,221110,221320,225230,227340,228930,230340,231270,231830,232450,233220,233520,234520,234860,236560,238310,239690,240700,241330,241580,241670,241970,241690,241410,242130,242130,243320,242030,242740,243050,243360,243940,244270,244350,244260,244230,245130,246740,247910,249590,251610,253430,255290,256710,257190,257820,257460,257970,259520,261340,263150) > 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/1lu6j1413463234.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/2y7501413463234.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/3q1841413463234.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.739999420 0.696816657 0.553064910 0.483941473 [6] 0.456210813 0.413167793 0.389273530 0.383300256 0.361865934 [11] 0.332586644 0.315793658 0.272652379 0.128363485 0.082219917 [16] -0.044196273 -0.060743249 -0.088317024 -0.123222317 -0.130189100 [21] -0.152315185 -0.134310192 -0.143183377 -0.131396269 -0.198611306 [26] -0.206405434 -0.226357387 -0.241516466 -0.211110466 -0.222167624 [31] -0.211643545 -0.174626854 -0.125462033 -0.048776972 -0.028588880 [36] 0.020970453 -0.013466036 0.005839038 -0.006087697 0.005953369 [41] -0.004395985 -0.020842684 0.003696128 0.019147602 0.081737750 [46] 0.104865781 0.090911604 0.081057892 0.020013493 > (mypacf <- c(rpacf$acf)) [1] 0.7399994199 0.3298347319 -0.0907260002 -0.0023377856 0.1453962579 [6] 0.0309037728 0.0007846839 0.0849571442 0.0302010449 -0.0417259889 [11] 0.0249271352 -0.0225976306 -0.3335138029 -0.0406724012 -0.1045182281 [16] -0.0345671235 0.0084894678 -0.0542450252 -0.0352114979 -0.0051484257 [21] 0.1156362250 0.0123105873 0.0386310929 -0.0878186116 0.0493389707 [26] 0.0389543799 -0.0106435609 -0.0109353287 -0.0427541955 -0.0516245434 [31] 0.0608495438 0.1301844634 0.0790046966 -0.0446683719 0.0846529535 [36] -0.0275262474 -0.0413680765 0.0244660482 -0.0415931588 -0.1442992771 [41] -0.0628197503 0.0452968907 -0.0504436212 0.0308343426 0.0264187059 [46] -0.0906649403 -0.0021236153 0.0097539617 > 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/42mcf1413463234.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/5ipfy1413463234.tab") > > try(system("convert tmp/1lu6j1413463234.ps tmp/1lu6j1413463234.png",intern=TRUE)) character(0) > try(system("convert tmp/2y7501413463234.ps tmp/2y7501413463234.png",intern=TRUE)) character(0) > try(system("convert tmp/3q1841413463234.ps tmp/3q1841413463234.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.199 1.387