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(220.05,220.05,220.62,221.53,221.61,221.5,221.5,221.87,222.27,220.86,221.49,221.67,221.67,221.72,221.67,220.29,220.75,219.59,219.59,219.59,219.82,221.59,220.9,221.01,221.01,219.69,221,219.82,218.04,217.97,217.97,217.53,217,217.18,217.68,217.71,217.71,218.5,218.8,218.94,220,219.89,219.89,220.08,220.16,221,222.16,221.5,221.5,221.6,221.85,223.11,222.79,222.45,222.45,222.4,223.15,224.4,224.24,223.92,212.42,212.34,212.95,213.37,214.26,214.1,213.54,213.69,211.82,212.82,212.36,212.7) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/1wayu1418487642.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/29ny21418487642.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/3rprj1418487642.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.862464839 0.721639361 0.589403910 0.468083946 [6] 0.396179687 0.311068968 0.221772053 0.133773215 0.000795894 [11] -0.094891077 -0.200942730 -0.301980378 -0.298297309 -0.307713356 [16] -0.300204357 -0.283934806 -0.279651500 -0.266497353 -0.254741905 [21] -0.248167842 -0.222100798 -0.202685729 -0.176397258 -0.136738648 [26] -0.097691192 -0.050761752 -0.003069329 0.038869619 0.080505228 [31] 0.119759640 0.155565552 0.195200329 0.200553405 0.187381003 [36] 0.193573376 0.171869825 0.149378078 0.128597892 0.087939053 [41] 0.073898926 0.065739021 0.058193040 0.057359233 0.029544187 [46] 0.024615298 0.010604517 -0.018571156 -0.027747174 -0.038657429 [51] -0.047585205 -0.042158944 -0.077733237 -0.106616017 -0.134664742 [56] -0.162527345 -0.182114403 -0.204683916 -0.203513162 -0.191261693 [61] -0.183676818 > (mypacf <- c(rpacf$acf)) [1] 0.8624648393 -0.0866908312 -0.0478790335 -0.0410311400 0.1117924966 [6] -0.1146451428 -0.0737856744 -0.0618211213 -0.2352558302 0.0222114638 [11] -0.1689690224 -0.1056154652 0.2701017536 -0.1016473901 0.0102019811 [16] 0.0218779676 0.0276681107 -0.0872618161 -0.0046208938 -0.0817839839 [21] -0.0885837213 0.0399604744 -0.1081369618 0.0279521858 0.1457278906 [26] -0.0221667000 0.0676070416 0.0664473200 0.0184033205 0.0094163542 [31] 0.0417806599 -0.0264481566 -0.1369691773 -0.0321944656 0.0453996796 [36] -0.1090101708 0.0490817973 0.0242793344 -0.0384705013 0.1572349952 [41] 0.0940405267 -0.0035963070 0.0601260733 -0.0145974641 -0.0593694833 [46] -0.0869440979 -0.0120779090 -0.1445178472 0.0445995972 0.0151109533 [51] -0.0217576765 -0.0184283477 0.0772288032 0.0077919568 -0.0008515952 [56] -0.0570120849 -0.0679978614 -0.0126923024 -0.0374921948 -0.0955231601 > 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/4al9l1418487642.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/5u85d1418487642.tab") > > try(system("convert tmp/1wayu1418487642.ps tmp/1wayu1418487642.png",intern=TRUE)) character(0) > try(system("convert tmp/29ny21418487642.ps tmp/29ny21418487642.png",intern=TRUE)) character(0) > try(system("convert tmp/3rprj1418487642.ps tmp/3rprj1418487642.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.219 0.202 1.427