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.93,2.02,1.85,1.77,1.81,1.67,1.55,1.62,1.79,1.73,1.77,1.95,2.08,2.26,2.02,1.9,1.97,1.76,1.93,1.91,1.96,1.99,1.98,1.96,1.95,2.26,2.07,2.02,2.07,1.88,1.75,1.78,1.87,1.94,2.03,2.13,2.04,2.18,2.02,1.99,2.09,1.88,1.8,1.77,1.85,1.9,2.03,2.02,2.09,2.3,2.16,2.02,2.31,1.98,1.74,1.82,2.07,2.04,2.07,2.13,2.14,2.43,2.26,2.11,2.19,2.04,2.04,2.05,2.08,1.98,2.07,2.12,2.15,2.35,2.19,2.17,2.3,2.09,1.95,1.89,1.95,1.98,1.95,2.06) > 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/12suv1384955738.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/29iy41384955738.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/3a4qf1384955738.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.1419870247 -0.1881836673 0.2137692624 -0.1379085790 [6] -0.1301765910 -0.1694345349 -0.0747879236 -0.1871779996 0.1884859090 [11] -0.0623666539 -0.1464625109 0.5899212573 -0.0961655212 -0.0530343269 [16] 0.2525295814 -0.1375244390 -0.0583588967 -0.1910840485 -0.1216492321 [21] -0.1475018761 0.1883298137 -0.1007602192 -0.1369681856 0.5540033651 [26] -0.0553180766 -0.1001260061 0.2531854614 -0.0502775902 -0.1657930819 [31] -0.1597215471 -0.0001388068 -0.1374900281 0.0650876603 0.0054492155 [36] -0.1362173994 0.3674303768 -0.0037405518 -0.0303005311 0.1567522853 [41] -0.0279384795 -0.0378882491 -0.1531198333 -0.0403331567 -0.0844459184 [46] 0.0659138848 -0.0794102695 -0.1117262700 0.3499096891 0.0111107019 [51] -0.0632722748 0.1044975459 -0.0218794346 -0.0536389765 -0.0806248169 [56] 0.0170158015 -0.0776000442 0.0095692554 -0.0067595096 -0.0688501038 [61] 0.1542013693 > (mypacf <- c(rpacf$acf)) [1] -0.141987025 -0.212630684 0.161593853 -0.132015785 -0.104194616 [6] -0.317438559 -0.175909519 -0.397740857 0.079670409 -0.321269598 [11] -0.270355282 0.268485239 -0.150827924 0.074097629 0.093670497 [16] -0.044012124 0.148441905 -0.186144192 -0.127778432 -0.092524070 [21] 0.048578122 -0.190248063 -0.053091194 0.057542562 0.037921896 [26] -0.114171278 0.049813186 0.049601414 -0.178197098 -0.127129589 [31] 0.031791001 -0.013895176 -0.039767850 0.065959691 -0.055561990 [36] -0.094593886 -0.039672379 -0.014920932 -0.086871067 -0.056836399 [41] 0.059925218 -0.066506472 0.004888885 0.088333735 0.085504537 [46] -0.106306772 0.024066668 -0.024845917 0.040658416 0.072406703 [51] -0.065591984 -0.104360373 -0.048286750 0.070560126 -0.012105695 [56] 0.088435501 0.026957791 0.005528729 0.012554315 -0.055093058 > 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/4or381384955738.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/5qvee1384955738.tab") > > try(system("convert tmp/12suv1384955738.ps tmp/12suv1384955738.png",intern=TRUE)) character(0) > try(system("convert tmp/29iy41384955738.ps tmp/29iy41384955738.png",intern=TRUE)) character(0) > try(system("convert tmp/3a4qf1384955738.ps tmp/3a4qf1384955738.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.655 0.553 3.182