R version 3.2.2 (2015-08-14) -- "Fire Safety" 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(467,475,470,442,433,427,410,406,429,425,431,408,454,459,441,420,416,400,401,398,442,458,476,447,511,514,513,511,498,490,495,486,530,539,555,548,615,634,645,634,630,635,642,637,675,679,676,660,716,730,717,694,670,641,626,604,630,634,635,619) > 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/1i7061445713135.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/2kzth1445713135.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/31d7z1445713135.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.0205050431 0.0954225418 -0.1505887505 0.2149704246 [6] -0.1655246373 -0.0598963876 -0.1731092212 0.2533231527 -0.2144288810 [11] -0.0134056856 -0.0822879166 0.6579164486 -0.0725091808 0.0508379198 [16] -0.1895876058 0.0977119645 -0.1769807798 -0.1558010352 -0.2186444278 [21] 0.1219629114 -0.2345245505 -0.0421934038 -0.0878033381 0.4138533495 [26] -0.0388388153 -0.0042412255 -0.1367941560 0.0709339219 -0.1101721230 [31] -0.1210306003 -0.1665395314 0.0521194037 -0.1915468824 -0.0814548674 [36] -0.0559816201 0.2512352083 0.0217757468 -0.0041697260 -0.0625614738 [41] 0.0433559337 -0.0490790942 -0.0567418296 -0.0306146586 0.0714732840 [46] -0.0551146848 0.0001954914 0.0176992959 0.1016435968 > (mypacf <- c(rpacf$acf)) [1] 0.0205050431 0.0950420461 -0.1557803413 0.2212529245 -0.1714413747 [6] -0.1054493001 -0.0757586880 0.2114646945 -0.2241004658 -0.0333400362 [11] 0.0533797964 0.6059945262 -0.2134921672 -0.0880281031 -0.0901337211 [16] -0.1635559216 0.0675995862 -0.1804938005 -0.0708800045 -0.2233187665 [21] 0.0688205030 0.0324772224 0.0361740186 -0.0950831915 0.0285798382 [26] -0.1048952740 0.0548488135 0.0252595998 -0.0715546470 0.0239554114 [31] -0.1032870656 -0.0076387646 -0.0993229111 -0.0891389497 -0.0385363551 [36] -0.1134910565 0.0088738861 -0.0126472691 -0.0463729259 -0.0665505984 [41] -0.0267893044 0.0372444594 0.1286861801 0.0005004995 0.0561721451 [46] 0.0893447522 -0.0508068464 -0.1367605747 > 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/4uyms1445713135.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/55t641445713135.tab") > > try(system("convert tmp/1i7061445713135.ps tmp/1i7061445713135.png",intern=TRUE)) character(0) > try(system("convert tmp/2kzth1445713135.ps tmp/2kzth1445713135.png",intern=TRUE)) character(0) > try(system("convert tmp/31d7z1445713135.ps tmp/31d7z1445713135.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.152 0.259 1.414