R version 3.0.1 (2013-05-16) -- "Good Sport" 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(13.29,13.34,13.41,13.45,13.52,13.52,13.53,13.55,13.52,13.51,13.55,13.56,13.62,13.69,13.67,13.66,13.69,13.69,13.7,13.73,13.79,13.8,13.84,13.84,13.88,13.97,14.06,14.11,14.13,14.15,14.2,14.28,14.3,14.33,14.4,14.4,14.42,14.51,14.64,14.68,14.72,14.73,14.76,14.78,14.83,14.84,14.85,14.87,14.87,14.96,15.08,15.08,15.12,15.12,15.1,15.16,15.22,15.28,15.29,15.32,15.4,15.44,15.48,15.52,15.6,15.61,15.66,15.69,15.75,15.82,15.81,15.82) > 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/fisher/rcomp/tmp/1lwf31369611073.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/fisher/rcomp/tmp/2sz5k1369611073.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/fisher/rcomp/tmp/3m2461369611073.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.179699196 -0.140260910 -0.053052030 -0.135008264 [6] -0.016616627 0.153578911 0.069542632 -0.030882974 -0.061447728 [11] -0.126620143 0.046677533 0.278628917 0.105401704 -0.074442206 [16] -0.216881154 -0.178212656 -0.144242193 0.141880042 0.078213868 [21] -0.199410132 -0.200854243 -0.029851790 -0.066298054 0.139383785 [26] 0.132380930 0.050819189 -0.037430977 -0.098228122 -0.070784700 [31] 0.132673642 0.044028985 -0.105331494 -0.099925799 0.012835368 [36] 0.036226288 0.072581631 0.164721654 0.085239958 0.007892102 [41] 0.012580540 -0.163910193 -0.039386008 0.018612572 -0.024360732 [46] -0.065505030 -0.018480486 0.012710606 0.061797265 -0.029393655 [51] -0.056999723 -0.039346862 -0.066163947 0.011487480 -0.023219434 [56] -0.033808575 0.058331448 -0.001353949 -0.034787732 -0.003040766 [61] -0.004072455 > (mypacf <- c(rpacf$acf)) [1] 0.1796991965 -0.1783106843 0.0092741343 -0.1607916704 0.0397755407 [6] 0.1104314552 0.0153668284 -0.0245104379 -0.0402813991 -0.0890674721 [11] 0.0966348221 0.2176105252 0.0110652818 -0.0550259758 -0.1903754318 [16] -0.0493768402 -0.1663060659 0.1312150885 -0.0995544584 -0.2198768654 [21] -0.1603099882 0.0857418895 -0.1022742480 0.0856917376 -0.0611952010 [26] 0.1545101667 0.0390115244 0.0883863812 0.0091290379 0.0567301039 [31] -0.1057896848 -0.0473466397 -0.0509768264 0.0458865325 -0.0363626458 [36] -0.1327987875 0.0496322894 -0.0166328506 0.1756446970 -0.0291896928 [41] -0.1406950727 -0.0634479062 0.0255554360 0.0250198594 0.0146522613 [46] -0.1026344107 0.0771687660 -0.0346473300 -0.0853807625 -0.0342845383 [51] -0.1024400515 -0.1377135475 0.1058259633 0.0005219908 0.0788758508 [56] -0.0163761884 0.0353022772 0.0093336809 0.0553059718 0.0206357853 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4yh701369611073.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/fisher/rcomp/tmp/5su0m1369611073.tab") > > try(system("convert tmp/1lwf31369611073.ps tmp/1lwf31369611073.png",intern=TRUE)) character(0) > try(system("convert tmp/2sz5k1369611073.ps tmp/2sz5k1369611073.png",intern=TRUE)) character(0) > try(system("convert tmp/3m2461369611073.ps tmp/3m2461369611073.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.677 0.340 2.004