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(876,819,610,757,840,745,662,563,624,588,754,705,661,737,542,709,787,689,601,467,555,471,718,676,700,781,596,779,727,692,560,517,572,491,639,585,596,617,445,615,571,592,580,487,540,546,649,620,593,528,492,570,592,512,475,405,540,472,567,538,508,578,466,540,515,550,485,355,386,365,417,356) > 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/19g2m1413534248.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/2gi6l1413534248.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/3sfz71413534248.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.000000e+00 5.940034e-01 4.814726e-01 3.633214e-01 2.806958e-01 [6] 3.568819e-01 2.057244e-01 2.860872e-01 1.164145e-01 1.957261e-01 [11] 2.656406e-01 2.849268e-01 4.887965e-01 2.582123e-01 2.197319e-01 [16] 1.491934e-01 1.270583e-01 1.839473e-01 7.082515e-02 1.369487e-01 [21] 2.174115e-02 6.838735e-02 1.347752e-01 1.216087e-01 2.602785e-01 [26] 7.156227e-02 3.160970e-02 -1.635268e-02 -5.629715e-02 -1.955936e-05 [31] -9.012027e-02 -2.956361e-02 -1.143514e-01 -9.565530e-02 -5.513391e-02 [36] -6.407238e-02 3.814508e-02 -1.049127e-01 -1.357615e-01 -1.821369e-01 [41] -2.093632e-01 -1.591759e-01 -2.369012e-01 -2.120458e-01 -2.542043e-01 [46] -1.905481e-01 -1.499184e-01 -1.178898e-01 -5.286138e-02 > (mypacf <- c(rpacf$acf)) [1] 0.594003440 0.198764629 0.025907894 0.007238740 0.229268462 [6] -0.157380784 0.181133266 -0.221738595 0.238431024 0.070557228 [11] 0.182315969 0.257262558 -0.249106951 -0.118449861 0.013725362 [16] -0.044559837 0.024964917 -0.005794913 0.019393930 0.025374337 [21] -0.041889990 0.034754309 -0.017384021 0.065155121 -0.141200767 [26] -0.064739401 -0.024614838 -0.070549015 -0.004755665 0.022824853 [31] -0.019095744 0.006711614 -0.074388769 -0.068865630 0.031723327 [36] -0.031080607 -0.040329291 -0.040298758 -0.053146659 -0.029559692 [41] -0.019328800 -0.060248161 -0.066597809 0.035980621 0.079595216 [46] -0.042816638 0.094797600 -0.064983047 > 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/44pw51413534248.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/5nz901413534248.tab") > > try(system("convert tmp/19g2m1413534248.ps tmp/19g2m1413534248.png",intern=TRUE)) character(0) > try(system("convert tmp/2gi6l1413534248.ps tmp/2gi6l1413534248.png",intern=TRUE)) character(0) > try(system("convert tmp/3sfz71413534248.ps tmp/3sfz71413534248.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.195 0.206 1.416