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(26.73,26.85,27.01,27.09,27.11,27.16,27.13,27.19,27.49,27.63,27.72,27.77,27.81,27.92,28.07,28.14,28.17,28.2,28.21,28.2,28.19,28.24,28.25,28.26,28.33,28.67,28.81,28.99,29.16,29.25,29.25,29.38,29.48,29.65,29.69,29.73,29.81,30.05,30.29,30.37,30.5,30.67,30.76,30.84,30.86,31.09,31.2,31.19,31.18,31.31,31.39,31.39,31.37,31.36,31.37,31.35,31.34,31.47,31.48,31.54) > 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/18ahb1338294833.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/23tn61338294833.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/3wh411338294833.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.3471757059 0.0156994083 0.0249967032 0.1225991802 [6] 0.0312428075 0.0168768184 -0.0341657595 0.0143730407 -0.1623461519 [11] -0.1906561932 -0.0425445931 0.2165875693 0.0571751286 -0.1170563524 [16] -0.2005378313 -0.0359730216 0.0691011684 -0.0801888596 -0.1452312489 [21] -0.0477102658 -0.2323129306 -0.2524692827 -0.0428468696 0.1097040089 [26] -0.0147174819 -0.1351028751 -0.1799261741 -0.0456385298 0.0715010613 [31] 0.0481021058 0.0004994324 0.1137830707 0.0191068897 -0.0127073935 [36] 0.0966988460 0.1368909450 0.1387508402 0.0391335494 -0.0536082213 [41] -0.0137849899 0.0355558829 0.0003960565 -0.0076477139 -0.0260455113 [46] -0.0639761337 -0.0413266903 -0.0094255335 0.0103115717 > (mypacf <- c(rpacf$acf)) [1] 0.347175706 -0.119198697 0.069528622 0.105282859 -0.058871151 [6] 0.045016955 -0.066932417 0.044082621 -0.216929704 -0.066905780 [11] 0.059156885 0.227240559 -0.072016844 -0.095906718 -0.155418373 [16] 0.024420712 0.103439514 -0.180729189 -0.058255401 -0.035882958 [21] -0.208036755 -0.025032807 0.079879334 -0.005597780 -0.111884982 [26] -0.053275770 -0.080822439 -0.042061326 0.016427787 -0.016997895 [31] -0.034984680 0.128083803 -0.020212844 -0.002879803 0.077313740 [36] -0.130705259 0.062746732 0.070780092 -0.029636821 -0.127689817 [41] -0.019980990 -0.038891951 -0.025362094 -0.020618473 -0.039115784 [46] -0.040476873 -0.044329428 -0.013036171 > 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/4lunc1338294833.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/5140b1338294833.tab") > > try(system("convert tmp/18ahb1338294833.ps tmp/18ahb1338294833.png",intern=TRUE)) character(0) > try(system("convert tmp/23tn61338294833.ps tmp/23tn61338294833.png",intern=TRUE)) character(0) > try(system("convert tmp/3wh411338294833.ps tmp/3wh411338294833.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.004 0.259 1.261