R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(95870,95523,95208,94541,101097,100781,95870,92581,92928,92928,93244,93910,93559,96190,97172,96190,99799,97488,92261,90964,90964,91599,89004,90964,89319,90964,93559,94541,96852,95870,89981,87670,86692,87670,86057,86692,84728,88021,89635,89981,96190,96190,88021,86057,86057,87039,82764,80799,78524,79186,82133,79821,86057,87039,80799,78524,77221,78524,74910,73613,68390,69688,70004,70355,76559,75893,68390,65097,63799,65444,59208,54964,47115,47777,47777,47115,52684,53004,46448,45151,42524,46133,39577,35653,28146,29764,27800,28462,33373,34355,31093,30742,30742,35017,27484,22573,14058,20929,19946,20293,28146,27164,23555,25204,25204,31093,24222,20293,14058,22258,21595,21911,28782,28146,25835,26186,27800,31409,25835,21275) > 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/18msm1344777610.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/2ynm91344777610.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/3b5lk1344777610.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.0242042063 -0.1068015380 -0.1574592773 -0.0011134904 [6] -0.0007637113 -0.0883801583 -0.0634425033 -0.0456936177 -0.1817028823 [11] -0.1052199905 0.0554497392 0.8093255721 0.0086374965 -0.0861482105 [16] -0.1362960576 0.0342919155 0.0424680491 -0.0971799678 -0.1084732498 [21] -0.1015456714 -0.1785535106 -0.1384151772 0.0585509565 0.6507758990 [26] -0.0063965873 -0.0776436582 -0.1205151576 0.0613885064 0.0959225608 [31] -0.0909254625 -0.1401495971 -0.1429625460 -0.1498373373 -0.1765950002 [36] 0.0276113769 0.5166616788 -0.0251876211 -0.0736986006 -0.0891682991 [41] 0.0934703561 0.1353502797 -0.0795829844 -0.1415355868 -0.1284810736 [46] -0.1299117491 -0.1818735080 0.0009421982 0.3897033788 > (mypacf <- c(rpacf$acf)) [1] 0.0242042063 -0.1074503307 -0.1538612308 -0.0070579165 -0.0346231678 [6] -0.1174726866 -0.0706515522 -0.0775878861 -0.2462626779 -0.1733688900 [11] -0.0479304070 0.7844234871 0.0255695286 0.0558497838 -0.0211769842 [16] -0.0216038494 -0.0157004902 -0.0458306235 -0.0319902772 -0.0915872372 [21] 0.0132670817 -0.1430411664 -0.0513828317 -0.0211064389 -0.0225509873 [26] -0.0307694576 -0.0413043575 -0.0321449599 0.0318281002 0.0232258738 [31] -0.0321974467 -0.0353069761 0.0436589185 -0.0967934128 -0.1132357412 [36] -0.0318252242 -0.0608033295 -0.0391775446 0.0154277781 -0.0040317457 [41] -0.0278169864 -0.0056641668 -0.0002973794 0.0637769440 -0.0097750185 [46] 0.0299021704 -0.0326968389 -0.0552721551 > 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/4xah71344777610.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/51q851344777610.tab") > > try(system("convert tmp/18msm1344777610.ps tmp/18msm1344777610.png",intern=TRUE)) character(0) > try(system("convert tmp/2ynm91344777610.ps tmp/2ynm91344777610.png",intern=TRUE)) character(0) > try(system("convert tmp/3b5lk1344777610.ps tmp/3b5lk1344777610.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.021 0.321 2.317