R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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(1.2103,1.1938,1.202,1.2271,1.277,1.265,1.2684,1.2811,1.2727,1.2611,1.2881,1.3213,1.2999,1.3074,1.3242,1.3516,1.3511,1.3419,1.3716,1.3622,1.3896,1.4227,1.4684,1.457,1.4718,1.4748,1.5527,1.5751,1.5557,1.5553,1.577,1.4975,1.4369,1.3322,1.2732,1.3449,1.3239,1.2785,1.305,1.319,1.365,1.4016,1.4088,1.4268,1.4562,1.4816,1.4914,1.4614,1.4272,1.3686,1.3569,1.3406,1.2565,1.2209,1.277,1.2894,1.3067,1.3898,1.3661,1.322,1.336,1.3649,1.3999,1.4442,1.4349,1.4388,1.4264,1.4343,1.377,1.3706,1.3556,1.3179,1.2905,1.3224,1.3201,1.3162,1.2789,1.2526,1.2288,1.24,1.2856,1.2974,1.2828,1.3119) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'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/1nwyz1384529843.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/2p1ye1384529843.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/32sbv1384529843.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.2855193862 -0.0007016425 0.1216372325 0.0254140041 [6] -0.0725680521 0.0014233680 -0.2327043028 -0.1969753398 -0.1576268341 [11] -0.1378084614 -0.1680122673 -0.1501414232 -0.1115306547 -0.0833631310 [16] 0.0576113770 0.2337163514 0.1079074989 0.1632523690 0.3000491036 [21] 0.1228860840 -0.0279819571 0.0592919378 -0.0832226966 -0.0476647124 [26] -0.0081626190 -0.0820174912 -0.0614879503 -0.0592018588 -0.1496825300 [31] -0.1360133456 -0.0701653344 -0.0713971431 -0.0669776055 -0.0022306071 [36] 0.1341433906 0.0849421706 0.0637853789 0.0155010845 0.1026917442 [41] 0.1007741072 0.0279432704 -0.0353506940 0.0647932934 0.0258899927 [46] 0.0140728848 -0.0461540326 -0.0173472391 -0.0896516499 -0.1053002526 [51] -0.0600724059 0.0023791724 -0.0301129034 0.0421687898 0.0100280073 [56] -0.0468142969 -0.0523413795 -0.0064613920 0.0194254141 0.0634097888 [61] -0.0009714332 > (mypacf <- c(rpacf$acf)) [1] 0.2855193862 -0.0895208176 0.1617961951 -0.0681651917 -0.0490971026 [6] 0.0245937963 -0.2826327183 -0.0163849419 -0.1660177382 -0.0121200452 [11] -0.1342583016 -0.1132610055 -0.0452580586 -0.1473676883 0.1079953071 [16] 0.1188788041 -0.0300491563 0.1374576602 0.1173850798 -0.0275730647 [21] -0.1190635390 0.0128439093 -0.1079870693 0.0598712795 0.0017386561 [26] 0.0405993546 0.1059046771 -0.0492654728 -0.0006152035 -0.0959890814 [31] 0.0084932365 -0.0872807747 -0.0596324207 -0.0461022312 0.0269676410 [36] 0.0053920441 -0.0158928152 -0.1120487380 0.1719670223 0.0039253011 [41] -0.0312699643 -0.0362848883 0.0323808282 -0.0151063673 0.0187542524 [46] -0.0513863751 0.1073321725 -0.0082493981 -0.0105547054 0.0279052190 [51] 0.0135561913 0.0383962024 0.0343038298 -0.0382442659 -0.1403382447 [56] -0.0610650723 -0.0120325248 0.0002574681 -0.0218531114 0.0376536490 > 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/40rqq1384529843.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/55nfd1384529843.tab") > > try(system("convert tmp/1nwyz1384529843.ps tmp/1nwyz1384529843.png",intern=TRUE)) character(0) > try(system("convert tmp/2p1ye1384529843.ps tmp/2p1ye1384529843.png",intern=TRUE)) character(0) > try(system("convert tmp/32sbv1384529843.ps tmp/32sbv1384529843.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.366 0.498 2.904