R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 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(13566.7,13941.5,14964.1,14086,13505.1,15300.4,14725.2,12484.9,16082.6,15915.8,15916.1,15713,14746,15253.2,18384.3,16848.5,16485.5,19257.1,17093.4,15700.1,19124.3,18640.8,18439.2,17106.3,18347.7,19372.7,22263.8,19422.9,21268.6,20310,19256,17535.9,19857.4,19628.4,19727.5,18112.2,18889.3,20516.1,22317,19768.8,20015.8,20260.5,19434.3,17910,19134.4,20880.1,19680,17493.4,19087.8,19064.6,21191,20503.9,20364.1,19860.4,20924.1,17018.8,20607.4,21500.2,19868.3,18801.9,19787.5,19936.2,21047.6,21034.4,20132.8,20725.3,20827.8,16992.3,21818.2,21841.4,19252.2,17933.7) > 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/1494h1457976049.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/2tt3h1457976049.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/3sbwd1457976049.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.00000000 -0.33971844 -0.25708930 0.07405913 0.15194196 -0.21653726 [7] 0.24283457 -0.21599901 0.19001074 0.02630804 -0.29858969 -0.09255035 [13] 0.63620152 -0.25589406 -0.15261273 -0.02381992 0.17822379 -0.14889835 [19] 0.11417428 -0.12600023 0.22679497 -0.14603923 -0.14985722 -0.04649987 [25] 0.37910251 -0.09338238 -0.13408348 -0.10116866 0.28033743 -0.19967610 [31] 0.03162775 0.04119241 0.09157528 -0.12748895 -0.02315543 -0.11652893 [37] 0.25957312 0.04573318 -0.22535752 -0.04240000 0.26265054 -0.22105511 [43] 0.06679906 0.07807160 -0.01799881 -0.06788767 0.02250704 -0.16010797 [49] 0.23514308 > (mypacf <- c(rpacf$acf)) [1] -0.3397184411 -0.4210960257 -0.2653587809 -0.0522854081 -0.2598004062 [6] 0.1564189394 -0.2166054362 0.2218881544 0.1735698181 -0.2810227292 [11] -0.3042278351 0.3190580705 0.2413634482 0.2207350947 -0.1329835736 [16] 0.0744903812 -0.0003265837 -0.0266615613 0.0182193052 0.0280859800 [21] -0.1007813925 0.0018953006 -0.1012939401 -0.1405653547 0.0325216217 [26] 0.0132125966 -0.0139315782 0.1447721059 -0.0550770403 0.0132619763 [31] 0.0600583165 -0.1057397301 0.1275951555 0.0389968413 0.0528647343 [36] -0.0635166556 0.0005644870 -0.0402446957 -0.0589233616 -0.0549924162 [41] -0.0228779924 0.0678486680 0.0794619556 -0.0313115101 -0.0656817515 [46] -0.0354120567 0.0272735253 -0.0191864945 > 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/4bx6m1457976049.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/51s6r1457976049.tab") > > try(system("convert tmp/1494h1457976049.ps tmp/1494h1457976049.png",intern=TRUE)) character(0) > try(system("convert tmp/2tt3h1457976049.ps tmp/2tt3h1457976049.png",intern=TRUE)) character(0) > try(system("convert tmp/3sbwd1457976049.ps tmp/3sbwd1457976049.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.352 0.236 1.597