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(66329,50326,47182,42247,45796,48233,40079,39596,41275,41875,29784,7199,56166,33936,34532,30261,30857,35461,33525,27825,33624,35618,27329,8081,62751,37565,44749,37537,36825,50679,38488,36522,45545,43571,37343,11593,74784,49019,56601,47634,49807,50499,42092,39064,44376,43616,41059,17226,70170,43949,52333,41034,47760,76115,30918,32994,31947,26763,30251,18211,47957,31901,35560,30408,30083,35044,30475,28308,31395,36311,40426,38948) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/1malm1416177885.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/21qay1416177885.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/3sibb1416177885.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.023708611 0.168099983 0.119976419 0.187458092 [6] 0.181985679 -0.202198105 0.102685928 0.116912321 -0.014633860 [11] -0.023284600 -0.222179080 0.546785244 -0.220500760 -0.096293999 [16] -0.141091682 -0.053902266 -0.032246759 -0.361684252 -0.128795450 [21] -0.060566579 -0.142351564 -0.134046132 -0.267142882 0.339923376 [26] -0.239974034 -0.116666940 -0.134115931 -0.063253869 -0.008500941 [31] -0.252821113 -0.063499010 0.014549153 -0.036280776 -0.022580772 [36] -0.103037761 0.286140986 -0.044486381 0.031353683 0.019361587 [41] 0.073897728 0.116956643 -0.079088859 0.053241023 0.115431449 [46] 0.084519631 0.090713779 0.026126471 0.224441087 > (mypacf <- c(rpacf$acf)) [1] 0.0237086106 0.1676321109 0.1160080229 0.1637088759 0.1560455675 [6] -0.2854274525 0.0096047994 0.1457531122 -0.0469907203 -0.0160141034 [11] -0.2177355509 0.5623433962 -0.3550344392 -0.2122169698 -0.1501187430 [16] -0.0619103429 -0.1141768264 -0.0001215193 -0.1270517023 -0.0769444397 [21] 0.0110753009 0.0031720083 0.0768707122 -0.0503056918 -0.0923671592 [26] -0.0773119865 -0.0068327213 -0.1294388555 -0.0605880889 -0.0139020361 [31] -0.0178093217 -0.0569559215 -0.0132961999 -0.0284087514 0.0056325494 [36] -0.1939431580 0.1391181115 0.0001258213 -0.0409780357 -0.0220329424 [41] 0.0127339250 -0.0879842344 0.0017818752 0.0098299538 -0.0037546151 [46] 0.0295183027 -0.0488424872 -0.0378521391 > 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/46j871416177885.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/5xt6i1416177885.tab") > > try(system("convert tmp/1malm1416177885.ps tmp/1malm1416177885.png",intern=TRUE)) character(0) > try(system("convert tmp/21qay1416177885.ps tmp/21qay1416177885.png",intern=TRUE)) character(0) > try(system("convert tmp/3sibb1416177885.ps tmp/3sibb1416177885.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.162 0.202 1.376