R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch" Copyright (C) 2016 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(480,548,634,489,399,658,497,495,445,525,565,427,477,511,538,444,559,433,459,492,526,523,636,519,671,599,579,593,684,599,721,516,556,700,579,552,734,760,714,698,800,712,782,610,596,748,581,641,598,609,526,716,552,464,631,465,539,537,488,520,477,480,645,455,379,477,424,316,381,376,389,472) > 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.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/18yfb1483639110.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/2ah9p1483639110.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/3mbok1483639110.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.5025515963 -0.1115028535 0.2353454984 -0.0263094258 [6] -0.0895143413 0.1096983053 -0.1740075650 0.0720765046 0.1539765216 [11] -0.2558778584 0.1121854016 0.1732637537 -0.3199835025 0.2261340856 [16] 0.0479653116 -0.2258491496 0.1854275711 -0.0152267861 -0.1317208464 [21] 0.0783346850 0.0997430174 -0.2089175394 0.1589722616 -0.0107714926 [26] -0.0884521399 0.0776781113 -0.0515752409 -0.0188491291 0.0892785229 [31] -0.1412483239 -0.0319569832 0.1802596346 -0.0937163879 -0.1396482126 [36] 0.2569456229 -0.1257966688 -0.0186697327 0.1172113948 -0.1575286571 [41] 0.1230627299 -0.0506218334 0.0003304031 -0.0257898403 0.0580923963 [46] -0.1252755793 0.1398869319 -0.0454034088 -0.1178616276 > (mypacf <- c(rpacf$acf)) [1] -0.5025515963 -0.4870759369 -0.1627123141 0.0334821097 0.0524971386 [6] 0.1450252216 -0.1553545564 -0.1957850358 0.0557025760 -0.0692299504 [11] 0.0156356728 0.2172387823 -0.1140923255 0.0254883991 0.0976683129 [16] -0.0396711948 0.0711328250 0.0135988418 -0.0267446282 -0.1494798768 [21] 0.0732239986 0.0267906848 -0.0094160383 0.0624706398 0.0205303661 [26] -0.1371700068 -0.1034037683 -0.0319426104 -0.0308883684 -0.0933663892 [31] -0.2044326186 -0.1278034115 -0.0243586919 -0.0686590512 0.1063351078 [36] 0.0316545547 0.0236816973 0.0733992614 -0.0823799053 0.1042512740 [41] -0.0324332821 0.1233218838 0.0641118444 -0.0512945525 -0.0821939388 [46] -0.0007988396 -0.0355969848 -0.0516270893 > 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/4j1c91483639110.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/5jovl1483639110.tab") > > try(system("convert tmp/18yfb1483639110.ps tmp/18yfb1483639110.png",intern=TRUE)) character(0) > try(system("convert tmp/2ah9p1483639110.ps tmp/2ah9p1483639110.png",intern=TRUE)) character(0) > try(system("convert tmp/3mbok1483639110.ps tmp/3mbok1483639110.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.332 0.112 1.465