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(2048,2037,2149,2124,2205,2489,2573,2702,2718,2646,2712,2634,2614,2637,2649,2579,2505,2462,2467,2447,2656,2626,2483,2540,2503,2467,2513,2443,2293,2071,2030,2052,1864,1670,1811,1905,1863,2014,2198,2962,3047,3033,3504,3801,3858,3674,3721,3844,4117,4105,4435,4296,4203,4563,4621,4697,4591,4357,4503,4444,4291,4200,4139,3970,3862,3702,3570,3801,3896,3918,3813,3667) > 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/fisher/rcomp/tmp/18eyt1354184948.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/2p7y61354184948.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/3ye3g1354184948.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.00000000 0.23554081 0.03389896 0.21124344 0.18219438 0.24636425 [7] -0.03739708 -0.07034970 0.10257528 -0.05555971 -0.18542289 0.07638021 [13] -0.10151160 -0.10823436 0.03319159 -0.08555353 0.01454826 -0.21922995 [19] -0.20766341 0.08715152 -0.15027831 -0.23381752 -0.21661100 -0.20569632 [25] -0.13625889 -0.11229880 -0.18893948 -0.11521534 -0.02575806 0.03328831 [31] 0.07279773 -0.10515767 0.03081660 0.11264948 0.10918385 0.08854697 [37] 0.02789619 0.09395785 0.07126613 -0.02198134 0.01081118 0.05102628 [43] 0.05611105 0.06799661 0.02396230 0.03006493 0.02146793 0.01821016 [49] 0.11664140 > (mypacf <- c(rpacf$acf)) [1] 0.2355408061 -0.0228481158 0.2208178212 0.0899799464 0.2153977917 [6] -0.1944585220 -0.0598330080 0.0171375908 -0.1153122096 -0.1703998667 [11] 0.2313736334 -0.1796809545 0.0142724211 0.1132372522 -0.0390473144 [16] -0.0505439711 -0.2058375097 -0.0776664527 0.0472259012 -0.1442133829 [21] -0.0311954130 -0.1911860756 -0.0853405858 -0.1155984268 0.0650322204 [26] -0.0609173986 -0.1116254079 0.0912854481 0.1485500585 -0.1255180229 [31] -0.0660984802 0.0285354431 -0.0905240430 0.0400570215 0.0399374403 [36] 0.0502287512 -0.0360843214 -0.0472811164 -0.1341109706 -0.1039429024 [41] -0.0482365937 0.0859813502 -0.0005922122 -0.0787167720 -0.0371392826 [46] -0.0319667660 -0.0628432510 -0.0489029709 > 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/492tl1354184948.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/591d41354184948.tab") > > try(system("convert tmp/18eyt1354184948.ps tmp/18eyt1354184948.png",intern=TRUE)) character(0) > try(system("convert tmp/2p7y61354184948.ps tmp/2p7y61354184948.png",intern=TRUE)) character(0) > try(system("convert tmp/3ye3g1354184948.ps tmp/3ye3g1354184948.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.694 0.473 2.154