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(3028,3017,3007,2986,3193,3183,3028,2924,2935,2935,2945,2966,2955,3038,3069,3038,3152,3079,2914,2873,2873,2893,2811,2873,2821,2873,2955,2986,3059,3028,2842,2769,2738,2769,2718,2738,2676,2780,2831,2842,3038,3038,2780,2718,2718,2749,2614,2552,2480,2501,2594,2521,2718,2749,2552,2480,2439,2480,2366,2325,2160,2201,2211,2222,2418,2397,2160,2056,2015,2067,1870,1736,1488,1509,1509,1488,1664,1674,1467,1426,1343,1457,1250,1126,889,940,878,899,1054,1085,982,971,971,1106,868,713,444,661,630,641,889,858,744,796,796,982,765,641,444,703,682,692,909,889,816,827,878,992,816,672) > 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/17lgq1343995193.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/219c21343995193.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/35pk71343995193.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.0000000000 0.0242047759 -0.1067284127 -0.1575201302 -0.0011416408 [6] -0.0007674833 -0.0883558038 -0.0634310280 -0.0456999228 -0.1817674587 [11] -0.1051481206 0.0554271120 0.8093285200 0.0086423329 -0.0860761663 [16] -0.1363282445 0.0342422455 0.0424895209 -0.0971747109 -0.1084292098 [21] -0.1016203788 -0.1785389987 -0.1384187340 0.0585676388 0.6507658476 [26] -0.0063575423 -0.0776370806 -0.1205377074 0.0613276420 0.0959604756 [31] -0.0909262769 -0.1401155047 -0.1430099258 -0.1498458456 -0.1765932881 [36] 0.0276225240 0.5166939379 -0.0252384276 -0.0736713291 -0.0891460790 [41] 0.0933920241 0.1353922545 -0.0795922972 -0.1415196399 -0.1284856947 [46] -0.1299644819 -0.1818590769 0.0009636462 0.3897142017 > (mypacf <- c(rpacf$acf)) [1] 0.0242047759 -0.1073771930 -0.1539242255 -0.0070681700 -0.0346164471 [6] -0.1174713726 -0.0706434575 -0.0775780083 -0.2463286959 -0.1732938284 [11] -0.0479404154 0.7844194522 0.0255200033 0.0558505090 -0.0210982165 [16] -0.0216045545 -0.0155741568 -0.0458839198 -0.0319225975 -0.0918348874 [21] 0.0134957785 -0.1432718288 -0.0512031363 -0.0211449247 -0.0224646843 [26] -0.0309448237 -0.0413763785 -0.0321218200 0.0317445152 0.0233291119 [31] -0.0323612925 -0.0350376183 0.0434267191 -0.0965993044 -0.1133619674 [36] -0.0316195130 -0.0611461216 -0.0390244558 0.0155438516 -0.0041231779 [41] -0.0277576940 -0.0056914165 -0.0002940416 0.0637593721 -0.0097905630 [46] 0.0298249275 -0.0326433942 -0.0553951719 > 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/4ocwr1343995193.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/5vejp1343995193.tab") > > try(system("convert tmp/17lgq1343995193.ps tmp/17lgq1343995193.png",intern=TRUE)) character(0) > try(system("convert tmp/219c21343995193.ps tmp/219c21343995193.png",intern=TRUE)) character(0) > try(system("convert tmp/35pk71343995193.ps tmp/35pk71343995193.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.270 0.247 1.510