R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(1200,1400,1210,1260,1320,1320,1310,1260,1340,1180,1330,1390,1130,1340,1140,1290,1260,1280,1330,1270,1300,1150,1410,1250,1030,1320,1160,1300,1190,1310,1290,1320,1300,1230,1330,1220,1010,1290,1170,1240,1260,1260,1310,1360,1250,1170,1360,1140,1030,1260,1210,1190,1230,1350,1300,1340,1270,1220,1400,1120,1000,1260,1260,1150,1240,1360,1350,1280,1320,1210,1370,1060,1040,1260,1210,1200,1200,1290,1400,1280,1280,1220,1350,1000,980,1240,1190,1200,1150,1270,1410,1420,1260,1300,1410,1000,950,1280,1330,1190,1170,1270,1340,1470,1270,1280,1430,980) > 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/www/rcomp/tmp/1487v1344873778.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/www/rcomp/tmp/2rb4p1344873778.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/www/rcomp/tmp/3h63n1344873778.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.051926941 -0.087052281 0.126941217 -0.049180509 [6] -0.182339051 -0.399601216 -0.178582686 -0.077054565 0.106832271 [11] -0.110436380 0.121356460 0.770000296 0.032403594 -0.041925442 [16] 0.091813175 -0.037635009 -0.191176739 -0.339206987 -0.190920997 [21] -0.096071955 0.127792048 -0.126115312 0.112233360 0.583724874 [26] 0.008341760 -0.004839875 0.062903658 -0.024322981 -0.159410218 [31] -0.270185525 -0.175812169 -0.061109682 0.116439706 -0.141043955 [36] 0.138806244 0.468973316 -0.042096917 0.012067915 0.075452425 [41] -0.039844071 -0.130746473 -0.211246466 -0.134912458 -0.065400234 [46] 0.093852502 -0.117846286 0.135726531 0.356710466 > (mypacf <- c(rpacf$acf)) [1] 0.051926941 -0.089991341 0.138028325 -0.075870843 -0.154085597 [6] -0.429979688 -0.215058702 -0.176553351 0.197628686 -0.197498772 [11] 0.041646718 0.659758347 0.036889077 0.007522364 -0.097104510 [16] -0.052398161 -0.028617801 0.082963736 -0.034963612 -0.044103304 [21] 0.079069482 -0.032776979 -0.119032713 -0.086227256 -0.102802942 [26] 0.005721121 0.016357206 0.027680722 0.038403853 0.018868512 [31] 0.015722167 0.044876410 -0.042464547 -0.042722563 0.083463553 [36] 0.117709289 -0.075145106 -0.022264118 0.023965813 -0.061692024 [41] 0.016049636 -0.027839443 0.020207310 -0.084314451 0.009249743 [46] 0.009624915 -0.043290517 -0.034034525 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/4xoh81344873778.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/www/rcomp/tmp/5aq4y1344873778.tab") > > try(system("convert tmp/1487v1344873778.ps tmp/1487v1344873778.png",intern=TRUE)) character(0) > try(system("convert tmp/2rb4p1344873778.ps tmp/2rb4p1344873778.png",intern=TRUE)) character(0) > try(system("convert tmp/3h63n1344873778.ps tmp/3h63n1344873778.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.910 0.320 1.207