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(3004,3080,3017,3114,3057,3032,3127,3050,2910,2671,2638,2672,2654,2568,2467,2419,2363,2291,2560,2527,2370,2310,2231,2367,2346,2286,2249,2226,2108,2131,2387,2358,2284,2312,2293,2576,2665,2749,2926,2886,2893,2944,3060,3045,2894,2955,2954,3243,3120,3074,3034,2981,2876,2835,2978,2881,2768,2722,2630,2753,2771,2652,2584,2501,2449,2445,2620,2579,2460,2434,2392,1037,1212,1232,1174,1158,1140,1118,1212,1207,1186,608,627,626,649,619,612,643,623,649,699,693,659,669,668,693) > 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/1yepj1419845280.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/2xlte1419845280.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/3qlr71419845280.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.956912385 0.914225872 0.873660130 0.830057469 [6] 0.787001382 0.744296220 0.696881790 0.647231777 0.598861188 [11] 0.554697125 0.500102236 0.446215352 0.387593179 0.327992440 [16] 0.270938729 0.227720390 0.186330987 0.146276891 0.099784600 [21] 0.051362995 0.004144687 -0.039853813 -0.078758780 -0.121953645 [26] -0.166428443 -0.180549791 -0.189225625 -0.197138311 -0.199865241 [31] -0.201646121 -0.209761751 -0.218327662 -0.225253150 -0.226017950 [36] -0.219968912 -0.214110069 -0.206957213 -0.205873113 -0.201722186 [41] -0.196100966 -0.188007167 -0.174706099 -0.167592795 -0.161441632 [46] -0.151283072 -0.139092885 -0.124657078 -0.113512073 > (mypacf <- c(rpacf$acf)) [1] 9.569124e-01 -1.726117e-02 2.880874e-03 -5.747981e-02 -1.700279e-02 [6] -2.160886e-02 -7.901712e-02 -5.557087e-02 -1.826978e-02 2.255380e-02 [11] -1.516519e-01 -2.862766e-02 -1.028078e-01 -4.426789e-02 -2.242358e-02 [16] 1.223501e-01 1.178433e-04 -3.537234e-03 -1.202827e-01 -7.457302e-02 [21] -2.679059e-02 -2.509697e-02 2.813040e-02 -9.188557e-02 -4.323990e-02 [26] 3.015772e-01 5.488322e-02 -3.643156e-02 2.059699e-02 8.990519e-03 [31] -6.520817e-02 -6.157207e-02 -5.730039e-02 4.982735e-02 9.259197e-02 [36] -9.201214e-02 1.445021e-02 -1.203228e-01 -2.265487e-02 -1.991113e-02 [41] 1.130204e-01 1.120965e-01 -3.587950e-02 -8.819833e-02 -3.216851e-02 [46] -8.552335e-05 -2.250939e-02 -1.457166e-02 > 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/49g4b1419845280.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/5m6941419845280.tab") > > try(system("convert tmp/1yepj1419845280.ps tmp/1yepj1419845280.png",intern=TRUE)) character(0) > try(system("convert tmp/2xlte1419845280.ps tmp/2xlte1419845280.png",intern=TRUE)) character(0) > try(system("convert tmp/3qlr71419845280.ps tmp/3qlr71419845280.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.389 0.232 1.626