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(1329,1385,1681,1591,1598,1557,1190,932,1664,1717,1567,1355,1430,1863,1868,1711,1873,2095,1379,1021,1999,2094,2026,1390,1744,2117,1823,1963,1816,1966,1309,1250,2184,2295,1870,1222,1640,2194,2179,1976,1850,2077,1658,1156,2400,2218,1802,1444,1804,1541,2206,1972,1815,1749,1492,1307,1916,2035,1855,1086,1951,1733,1868,1532,1894,1586,1247,1212,2119,1931,1649,1296,1625,1454,1562,1612,1648,1412,1219,1207,1614,1537,1497,1141,1135,1368,1203,1201,1190,1347,607,914,1606,1518,1120,910) > 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/1fmey1425584384.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/25gfe1425584384.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/33a3z1425584384.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.000000000 0.397159210 0.004864811 0.108043772 0.447086636 [6] 0.359447464 0.284025641 0.349704564 0.299280819 -0.012852556 [11] -0.041548349 0.273430861 0.608486488 0.173720516 -0.135566500 [16] -0.096482626 0.200616013 0.162786680 0.093933881 0.131751604 [21] 0.093456889 -0.154701543 -0.192194972 0.140273259 0.397858816 [26] 0.010829500 -0.283182163 -0.165645962 0.084308110 0.008684252 [31] -0.040280838 0.029817197 -0.066926139 -0.268660460 -0.253723709 [36] 0.030525579 0.182099035 -0.133258342 -0.307467906 -0.222007271 [41] -0.078303911 -0.111998985 -0.111571663 -0.067878370 -0.152653199 [46] -0.292726973 -0.266927561 -0.032463235 0.076528843 > (mypacf <- c(rpacf$acf)) [1] 0.397159210 -0.181499536 0.218343941 0.395481830 0.048807117 [6] 0.294494538 0.285646309 0.002027746 -0.292653934 -0.219712529 [11] -0.036533142 0.436872250 -0.155972710 -0.032062434 -0.212548397 [16] -0.093534252 -0.005849282 -0.033032283 0.071462489 0.096836969 [21] 0.015756463 -0.089472450 0.064203073 0.046744791 -0.081000955 [26] -0.089557188 0.026948890 -0.084107409 -0.066793248 -0.036867321 [31] -0.010807956 -0.080850338 0.043385971 -0.009422057 -0.062061791 [36] 0.008321072 -0.085353469 0.146996634 -0.010782229 -0.133462405 [41] -0.034781771 -0.067097768 -0.059203514 0.077678597 0.036136176 [46] 0.044045779 0.004217513 -0.066031490 > 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/4hnl71425584384.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/5af6x1425584384.tab") > > try(system("convert tmp/1fmey1425584384.ps tmp/1fmey1425584384.png",intern=TRUE)) character(0) > try(system("convert tmp/25gfe1425584384.ps tmp/25gfe1425584384.png",intern=TRUE)) character(0) > try(system("convert tmp/33a3z1425584384.ps tmp/33a3z1425584384.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.169 0.245 1.423