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(500,510,590,490,540,530,550,510,390,480,530,690,570,460,540,510,520,520,580,480,410,530,540,670,570,400,510,570,470,640,650,500,340,450,600,680,630,480,400,520,470,610,670,500,290,470,660,650,570,500,400,500,340,530,680,480,340,460,630,650,550,470,240,430,390,570,700,620,280,480,560,560,560,550,140,380,390,500,750,680,280,360,590,580,490,610,170,320,440,510,770,660,300,350,580,620,490,640,150,290,370,560,780,690,310,280,590,590) > 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/14muz1344860026.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/25u3q1344860026.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/350qr1344860026.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.100950540 -0.333800142 -0.176683827 -0.152172068 [6] -0.006903439 0.478361498 0.088067931 -0.192733855 -0.143800411 [11] -0.248883857 -0.142151518 0.772071965 0.050764816 -0.337144977 [16] -0.151491196 -0.071977338 -0.107185866 0.388666535 0.162983703 [21] -0.134641843 -0.190395023 -0.160667771 -0.154987462 0.580073482 [26] 0.153355409 -0.305075026 -0.153302476 -0.021017510 -0.135063868 [31] 0.279174389 0.197314529 -0.062322065 -0.202234006 -0.114501012 [36] -0.132696394 0.378386108 0.203722903 -0.216617171 -0.153536214 [41] -0.002103484 -0.120653124 0.141007104 0.232881734 -0.002173338 [46] -0.187997201 -0.099479130 -0.098608344 0.228403708 > (mypacf <- c(rpacf$acf)) [1] -0.100950540 -0.347532865 -0.295515662 -0.445206892 -0.535972428 [6] -0.081310836 -0.109928102 -0.034402495 0.056937523 -0.229420586 [11] -0.655268794 0.219027078 -0.008138120 -0.091256896 0.041147343 [16] 0.184594250 0.075079069 -0.001822360 -0.030718449 0.171435292 [21] -0.089375696 -0.056330400 -0.005178712 0.002655491 -0.004509798 [26] -0.033868045 0.037206568 0.038490973 0.018022650 0.021190066 [31] -0.056217897 -0.001712171 0.031613053 0.004284450 0.089622704 [36] -0.047879635 0.003689565 0.025300335 -0.005519459 -0.034051219 [41] 0.048864727 -0.110494253 0.006650962 -0.086815022 -0.015876948 [46] -0.017994136 -0.012931568 0.015157462 > 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/4c4bz1344860026.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/5ipor1344860026.tab") > > try(system("convert tmp/14muz1344860026.ps tmp/14muz1344860026.png",intern=TRUE)) character(0) > try(system("convert tmp/25u3q1344860026.ps tmp/25u3q1344860026.png",intern=TRUE)) character(0) > try(system("convert tmp/350qr1344860026.ps tmp/350qr1344860026.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.213 0.229 1.449