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(109.03,110.43,111.01,111.01,110.76,111.13,111.07,111.09,110.96,110.64,110.62,110.59,111.33,113.94,114.61,114.64,114.62,114.71,114.72,114.66,114.76,114.68,114.75,114.74,116.36,117.53,118.82,119.83,119.97,121.29,120.94,121.02,120.98,121.02,120.89,120.76,123.28,123.98,125.91,125.84,125.98,127.24,127.23,127.82,127.59,127.74,127.44,127.35,128.54,129.3,130.67,130.76,131.34,130.69,130.96,130.68,130.61,130.59,130.44,129.04,131.46,132.77,134.48,134.52,136.11,136.12,136.03,135.84,137.75,137.45,136.84,136.79,140.12,140.68,140.35,140.42,140.19,140.14,140.13,139.45,139.59,139.44,139.53,139.28) > 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/15bo11413829698.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/2t0e31413829698.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/38f331413829698.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.0920077914 0.0525189477 -0.1544922697 0.0624676098 [6] -0.1705367816 -0.2185884813 -0.1287884424 -0.0431426845 -0.1882180869 [11] 0.0325400323 0.1559318862 0.5011226759 0.0177912247 0.0864426668 [16] -0.1784846810 -0.0422790715 -0.2019777032 -0.1756661371 -0.1345096637 [21] -0.0928719835 -0.1313698881 0.0171384305 0.1942089091 0.3260993833 [26] 0.1514969914 0.0492535014 -0.0624828329 -0.0011463433 -0.1585814427 [31] -0.1005056129 -0.0328499207 -0.0694606583 -0.1404781851 0.0027969416 [36] 0.1628421628 0.2732784593 0.1280488571 -0.0425994210 -0.0008118221 [41] -0.0686240874 -0.1106518868 -0.0972749184 -0.0397108979 -0.0241353747 [46] -0.1010301679 -0.0457085504 0.1258636763 0.1765269389 > (mypacf <- c(rpacf$acf)) [1] 0.092007791 0.044429630 -0.164916481 0.092723237 -0.176645518 [6] -0.230793371 -0.047861404 -0.080988294 -0.256575526 0.050742219 [11] 0.101998524 0.400250953 -0.047516082 0.030271923 -0.194205057 [16] -0.152382222 -0.064361225 -0.111402129 -0.037941022 -0.023930178 [21] -0.064129596 -0.086203373 0.042941308 -0.006066043 0.124494310 [26] -0.051044773 0.037997349 0.043255453 -0.051872297 0.034653894 [31] 0.112252887 -0.008259035 -0.075731144 -0.015054325 -0.090825724 [36] 0.080115118 0.015213327 -0.121931894 0.034781747 -0.039036327 [41] -0.009022018 0.011560490 0.003859644 0.105757708 0.055541558 [46] -0.071645457 0.012927206 -0.085611563 > 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/4tz3x1413829698.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/5hstm1413829698.tab") > > try(system("convert tmp/15bo11413829698.ps tmp/15bo11413829698.png",intern=TRUE)) character(0) > try(system("convert tmp/2t0e31413829698.ps tmp/2t0e31413829698.png",intern=TRUE)) character(0) > try(system("convert tmp/38f331413829698.ps tmp/38f331413829698.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.186 0.202 1.399