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(123,146,156,127,128,147,128,139,130,118,147,98,141,138,130,145,123,116,90,110,102,109,111,93,120,81,84,87,110,90,108,101,87,118,82,86,103,93,83,91,69,95,96,105,121,101,111,130,134,161,186,244,145,170,164,124,154,126,173,140,142,129,171,107,98,185,142,135,126,126,134,119,134,133,129,96,150,113,99,164,127,148,166,115,199,141,149,131,171,178,181,129,112,186,153,116,190,169,165,160,202,155,257,171,168,202,189,132) > 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/1tosc1413362350.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/29r401413362350.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/3r6ze1413362350.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.506336509 0.541131146 0.568647428 0.454556669 [6] 0.411428837 0.366991995 0.335676135 0.304341884 0.317577308 [11] 0.129402748 0.169758268 0.215805269 0.056114842 0.223477301 [16] 0.104871603 0.112746424 0.105170167 0.084434423 -0.006982503 [21] 0.026423386 0.014958319 -0.054852125 0.015830284 -0.111905290 [26] -0.142666858 -0.069405079 -0.159671180 -0.043163823 -0.057342739 [31] -0.067061600 -0.011439191 -0.012404599 -0.055099975 0.016679955 [36] 0.057643358 0.006550123 0.092677719 0.056397940 0.022187059 [41] 0.057275939 -0.005489905 -0.015103596 0.049902129 0.026215906 [46] 0.012046759 0.098720315 0.004685658 0.038160080 > (mypacf <- c(rpacf$acf)) [1] 0.5063365093 0.3829283867 0.3241225827 0.0544700028 -0.0265162442 [6] -0.0524068492 -0.0008855339 0.0198189361 0.0961688421 -0.2344257269 [11] -0.0694222409 0.1293080035 -0.0613262225 0.2515804923 -0.0683018710 [16] -0.0320028053 -0.0738544055 -0.0032487258 -0.1041589684 -0.0250721379 [21] -0.0358779262 -0.0079316161 0.0224142057 -0.0880311453 -0.1070417646 [26] 0.0298431943 0.0530537181 0.2223296331 0.0729590792 -0.0854376561 [31] 0.0309645466 -0.0593394868 0.0362298089 0.0846860460 0.0154695428 [36] -0.0290876430 -0.0016330384 -0.0097902885 0.0176820825 -0.0536291380 [41] -0.0200674963 -0.0792909975 0.0602314339 0.0410844390 -0.0009895074 [46] 0.0794179665 -0.0633012589 0.0371485282 > 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/4bjyg1413362350.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/564iz1413362350.tab") > > try(system("convert tmp/1tosc1413362350.ps tmp/1tosc1413362350.png",intern=TRUE)) character(0) > try(system("convert tmp/29r401413362350.ps tmp/29r401413362350.png",intern=TRUE)) character(0) > try(system("convert tmp/3r6ze1413362350.ps tmp/3r6ze1413362350.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.195 1.377