R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(1.4816,1.4562,1.4268,1.4088,1.4016,1.3650,1.3190,1.3050,1.2785,1.3239,1.3449,1.2732,1.3322,1.4369,1.4975,1.5770,1.5553,1.5557,1.5750,1.5527,1.4748,1.4718,1.4570,1.4684,1.4227,1.3896,1.3622,1.3716,1.3419,1.3511,1.3516,1.3242,1.3074,1.2999,1.3213,1.2881,1.2611,1.2727,1.2811,1.2684,1.2650,1.2770,1.2271,1.2020,1.1938,1.2103,1.1856,1.1786,1.2015,1.2256,1.2292,1.2037,1.2165,1.2694,1.2938,1.3201,1.3014,1.3119,1.3408,1.2991) > par9 = '0' > par8 = '0' > par7 = '0' > par6 = '3' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = 'FALSE' > library(lattice) > if (par1 == 'TRUE') par1 <- TRUE > if (par1 == 'FALSE') par1 <- FALSE > par2 <- as.numeric(par2) #Box-Cox lambda transformation parameter > par3 <- as.numeric(par3) #degree of non-seasonal differencing > par4 <- as.numeric(par4) #degree of seasonal differencing > par5 <- as.numeric(par5) #seasonal period > par6 <- as.numeric(par6) #degree (p) of the non-seasonal AR(p) polynomial > par6 <- 11 > par7 <- as.numeric(par7) #degree (q) of the non-seasonal MA(q) polynomial > par8 <- as.numeric(par8) #degree (P) of the seasonal AR(P) polynomial > par9 <- as.numeric(par9) #degree (Q) of the seasonal MA(Q) polynomial > armaGR <- function(arima.out, names, n){ + try1 <- arima.out$coef + try2 <- sqrt(diag(arima.out$var.coef)) + try.data.frame <- data.frame(matrix(NA,ncol=4,nrow=length(names))) + dimnames(try.data.frame) <- list(names,c('coef','std','tstat','pv')) + try.data.frame[,1] <- try1 + for(i in 1:length(try2)) try.data.frame[which(rownames(try.data.frame)==names(try2)[i]),2] <- try2[i] + try.data.frame[,3] <- try.data.frame[,1] / try.data.frame[,2] + try.data.frame[,4] <- round((1-pt(abs(try.data.frame[,3]),df=n-(length(try2)+1)))*2,5) + vector <- rep(NA,length(names)) + vector[is.na(try.data.frame[,4])] <- 0 + maxi <- which.max(try.data.frame[,4]) + continue <- max(try.data.frame[,4],na.rm=TRUE) > .05 + vector[maxi] <- 0 + list(summary=try.data.frame,next.vector=vector,continue=continue) + } > arimaSelect <- function(series, order=c(13,0,0), seasonal=list(order=c(2,0,0),period=12), include.mean=F){ + nrc <- order[1]+order[3]+seasonal$order[1]+seasonal$order[3] + coeff <- matrix(NA, nrow=nrc*2, ncol=nrc) + pval <- matrix(NA, nrow=nrc*2, ncol=nrc) + mylist <- rep(list(NULL), nrc) + names <- NULL + if(order[1] > 0) names <- paste('ar',1:order[1],sep='') + if(order[3] > 0) names <- c( names , paste('ma',1:order[3],sep='') ) + if(seasonal$order[1] > 0) names <- c(names, paste('sar',1:seasonal$order[1],sep='')) + if(seasonal$order[3] > 0) names <- c(names, paste('sma',1:seasonal$order[3],sep='')) + arima.out <- arima(series, order=order, seasonal=seasonal, include.mean=include.mean, method='ML') + mylist[[1]] <- arima.out + last.arma <- armaGR(arima.out, names, length(series)) + mystop <- FALSE + i <- 1 + coeff[i,] <- last.arma[[1]][,1] + pval [i,] <- last.arma[[1]][,4] + i <- 2 + aic <- arima.out$aic + while(!mystop){ + mylist[[i]] <- arima.out + arima.out <- arima(series, order=order, seasonal=seasonal, include.mean=include.mean, method='ML', fixed=last.arma$next.vector) + aic <- c(aic, arima.out$aic) + last.arma <- armaGR(arima.out, names, length(series)) + mystop <- !last.arma$continue + coeff[i,] <- last.arma[[1]][,1] + pval [i,] <- last.arma[[1]][,4] + i <- i+1 + } + list(coeff, pval, mylist, aic=aic) + } > arimaSelectplot <- function(arimaSelect.out,noms,choix){ + noms <- names(arimaSelect.out[[3]][[1]]$coef) + coeff <- arimaSelect.out[[1]] + k <- min(which(is.na(coeff[,1])))-1 + coeff <- coeff[1:k,] + pval <- arimaSelect.out[[2]][1:k,] + aic <- arimaSelect.out$aic[1:k] + coeff[coeff==0] <- NA + n <- ncol(coeff) + if(missing(choix)) choix <- k + layout(matrix(c(1,1,1,2, + 3,3,3,2, + 3,3,3,4, + 5,6,7,7),nr=4), + widths=c(10,35,45,15), + heights=c(30,30,15,15)) + couleurs <- rainbow(75)[1:50]#(50) + ticks <- pretty(coeff) + par(mar=c(1,1,3,1)) + plot(aic,k:1-.5,type='o',pch=21,bg='blue',cex=2,axes=F,lty=2,xpd=NA) + points(aic[choix],k-choix+.5,pch=21,cex=4,bg=2,xpd=NA) + title('aic',line=2) + par(mar=c(3,0,0,0)) + plot(0,axes=F,xlab='',ylab='',xlim=range(ticks),ylim=c(.1,1)) + rect(xleft = min(ticks) + (0:49)/50*(max(ticks)-min(ticks)), + xright = min(ticks) + (1:50)/50*(max(ticks)-min(ticks)), + ytop = rep(1,50), + ybottom= rep(0,50),col=couleurs,border=NA) + axis(1,ticks) + rect(xleft=min(ticks),xright=max(ticks),ytop=1,ybottom=0) + text(mean(coeff,na.rm=T),.5,'coefficients',cex=2,font=2) + par(mar=c(1,1,3,1)) + image(1:n,1:k,t(coeff[k:1,]),axes=F,col=couleurs,zlim=range(ticks)) + for(i in 1:n) for(j in 1:k) if(!is.na(coeff[j,i])) { + if(pval[j,i]<.01) symb = 'green' + else if( (pval[j,i]<.05) & (pval[j,i]>=.01)) symb = 'orange' + else if( (pval[j,i]<.1) & (pval[j,i]>=.05)) symb = 'red' + else symb = 'black' + polygon(c(i+.5 ,i+.2 ,i+.5 ,i+.5), + c(k-j+0.5,k-j+0.5,k-j+0.8,k-j+0.5), + col=symb) + if(j==choix) { + rect(xleft=i-.5, + xright=i+.5, + ybottom=k-j+1.5, + ytop=k-j+.5, + lwd=4) + text(i, + k-j+1, + round(coeff[j,i],2), + cex=1.2, + font=2) + } + else{ + rect(xleft=i-.5,xright=i+.5,ybottom=k-j+1.5,ytop=k-j+.5) + text(i,k-j+1,round(coeff[j,i],2),cex=1.2,font=1) + } + } + axis(3,1:n,noms) + par(mar=c(0.5,0,0,0.5)) + plot(0,axes=F,xlab='',ylab='',type='n',xlim=c(0,8),ylim=c(-.2,.8)) + cols <- c('green','orange','red','black') + niv <- c('0','0.01','0.05','0.1') + for(i in 0:3){ + polygon(c(1+2*i ,1+2*i ,1+2*i-.5 ,1+2*i), + c(.4 ,.7 , .4 , .4), + col=cols[i+1]) + text(2*i,0.5,niv[i+1],cex=1.5) + } + text(8,.5,1,cex=1.5) + text(4,0,'p-value',cex=2) + box() + residus <- arimaSelect.out[[3]][[choix]]$res + par(mar=c(1,2,4,1)) + acf(residus,main='') + title('acf',line=.5) + par(mar=c(1,2,4,1)) + pacf(residus,main='') + title('pacf',line=.5) + par(mar=c(2,2,4,1)) + qqnorm(residus,main='') + title('qq-norm',line=.5) + qqline(residus) + residus + } > if (par2 == 0) x <- log(x) > if (par2 != 0) x <- x^par2 > (selection <- arimaSelect(x, order=c(par6,par3,par7), seasonal=list(order=c(par8,par4,par9), period=par5))) [[1]] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.2665761 -0.10624895 0.1523487 0.05592994 0.07639750 -0.04896691 [2,] 0.2712183 -0.10438418 0.1497009 0.06844819 0.07795112 -0.04890954 [3,] 0.2701780 -0.10853031 0.1427102 0.07601904 0.06418058 0.00000000 [4,] 0.2437482 -0.10530514 0.1428822 0.08156784 0.07095604 0.00000000 [5,] 0.2459884 -0.08680665 0.1378099 0.07978523 0.06263204 0.00000000 [6,] 0.2495867 -0.08175145 0.1342728 0.09903459 0.00000000 0.00000000 [7,] 0.2230651 0.00000000 0.1094800 0.10942833 0.00000000 0.00000000 [8,] 0.2277100 0.00000000 0.1483644 0.10884284 0.00000000 0.00000000 [9,] 0.2424620 0.00000000 0.1736718 0.00000000 0.00000000 0.00000000 [10,] 0.2464394 0.00000000 0.0000000 0.00000000 0.00000000 0.00000000 [11,] NA NA NA NA NA NA [12,] NA NA NA NA NA NA [13,] NA NA NA NA NA NA [14,] NA NA NA NA NA NA [15,] NA NA NA NA NA NA [16,] NA NA NA NA NA NA [17,] NA NA NA NA NA NA [18,] NA NA NA NA NA NA [19,] NA NA NA NA NA NA [20,] NA NA NA NA NA NA [21,] NA NA NA NA NA NA [22,] NA NA NA NA NA NA [,7] [,8] [,9] [,10] [,11] [1,] -0.3247279 0.06477229 -0.06219610 -0.07441777 -0.03649366 [2,] -0.3286538 0.06160968 -0.06105455 -0.08457649 0.00000000 [3,] -0.3425671 0.06907224 -0.06982317 -0.09017172 0.00000000 [4,] -0.3270365 0.00000000 -0.05083026 -0.09901155 0.00000000 [5,] -0.3253192 0.00000000 0.00000000 -0.11215823 0.00000000 [6,] -0.3295304 0.00000000 0.00000000 -0.10430050 0.00000000 [7,] -0.3364072 0.00000000 0.00000000 -0.10351916 0.00000000 [8,] -0.3566358 0.00000000 0.00000000 0.00000000 0.00000000 [9,] -0.3439762 0.00000000 0.00000000 0.00000000 0.00000000 [10,] -0.3255229 0.00000000 0.00000000 0.00000000 0.00000000 [11,] NA NA NA NA NA [12,] NA NA NA NA NA [13,] NA NA NA NA NA [14,] NA NA NA NA NA [15,] NA NA NA NA NA [16,] NA NA NA NA NA [17,] NA NA NA NA NA [18,] NA NA NA NA NA [19,] NA NA NA NA NA [20,] NA NA NA NA NA [21,] NA NA NA NA NA [22,] NA NA NA NA NA [[2]] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 0.05061 0.43681 0.26545 0.68053 0.55599 0.70641 0.01582 0.64224 0.65859 [2,] 0.04502 0.44398 0.27255 0.58959 0.54795 0.70700 0.01397 0.65737 0.66420 [3,] 0.04587 0.42517 0.29039 0.54353 0.60598 NA 0.00775 0.61575 0.61492 [4,] 0.04996 0.43936 0.29045 0.51640 0.56798 NA 0.00876 NA 0.70349 [5,] 0.04841 0.49515 0.30509 0.52532 0.60973 NA 0.00918 NA NA [6,] 0.04483 0.51932 0.31804 0.41053 NA NA 0.00824 NA NA [7,] 0.05635 NA 0.39604 0.36132 NA NA 0.00695 NA NA [8,] 0.05422 NA 0.21948 0.36643 NA NA 0.00383 NA NA [9,] 0.03953 NA 0.14235 NA NA NA 0.00500 NA NA [10,] 0.04100 NA NA NA NA NA 0.00891 NA NA [11,] NA NA NA NA NA NA NA NA NA [12,] NA NA NA NA NA NA NA NA NA [13,] NA NA NA NA NA NA NA NA NA [14,] NA NA NA NA NA NA NA NA NA [15,] NA NA NA NA NA NA NA NA NA [16,] NA NA NA NA NA NA NA NA NA [17,] NA NA NA NA NA NA NA NA NA [18,] NA NA NA NA NA NA NA NA NA [19,] NA NA NA NA NA NA NA NA NA [20,] NA NA NA NA NA NA NA NA NA [21,] NA NA NA NA NA NA NA NA NA [22,] NA NA NA NA NA NA NA NA NA [,10] [,11] [1,] 0.59744 0.79859 [2,] 0.53180 NA [3,] 0.50290 NA [4,] 0.45897 NA [5,] 0.38603 NA [6,] 0.41734 NA [7,] 0.42198 NA [8,] NA NA [9,] NA NA [10,] NA NA [11,] NA NA [12,] NA NA [13,] NA NA [14,] NA NA [15,] NA NA [16,] NA NA [17,] NA NA [18,] NA NA [19,] NA NA [20,] NA NA [21,] NA NA [22,] NA NA [[3]] [[3]][[1]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 0.2666 -0.1062 0.1523 0.0559 0.0764 -0.0490 -0.3247 0.0648 s.e. 0.1330 0.1355 0.1352 0.1350 0.1288 0.1292 0.1298 0.1385 ar9 ar10 ar11 -0.0622 -0.0744 -0.0365 s.e. 0.1399 0.1400 0.1422 sigma^2 estimated as 0.000859: log likelihood = 123.87, aic = -223.74 [[3]][[2]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 0.2666 -0.1062 0.1523 0.0559 0.0764 -0.0490 -0.3247 0.0648 s.e. 0.1330 0.1355 0.1352 0.1350 0.1288 0.1292 0.1298 0.1385 ar9 ar10 ar11 -0.0622 -0.0744 -0.0365 s.e. 0.1399 0.1400 0.1422 sigma^2 estimated as 0.000859: log likelihood = 123.87, aic = -223.74 [[3]][[3]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 0.2712 -0.1044 0.1497 0.0684 0.0780 -0.0489 -0.3287 0.0616 s.e. 0.1318 0.1353 0.1349 0.1261 0.1288 0.1294 0.1289 0.1381 ar9 ar10 ar11 -0.0611 -0.0846 0 s.e. 0.1398 0.1343 0 sigma^2 estimated as 0.0008601: log likelihood = 123.84, aic = -225.68 [[3]][[4]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 0.2702 -0.1085 0.1427 0.0760 0.0642 0 -0.3426 0.0691 -0.0698 s.e. 0.1319 0.1350 0.1336 0.1243 0.1236 0 0.1235 0.1368 0.1379 ar10 ar11 -0.0902 0 s.e. 0.1336 0 sigma^2 estimated as 0.0008623: log likelihood = 123.77, aic = -227.54 [[3]][[5]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 0.2437 -0.1053 0.1429 0.0816 0.0710 0 -0.327 0 -0.0508 s.e. 0.1214 0.1351 0.1338 0.1248 0.1235 0 0.120 0 0.1328 ar10 ar11 -0.0990 0 s.e. 0.1327 0 sigma^2 estimated as 0.0008665: log likelihood = 123.64, aic = -229.28 [[3]][[6]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 ar10 0.2460 -0.0868 0.1378 0.0798 0.0626 0 -0.3253 0 0 -0.1122 s.e. 0.1217 0.1264 0.1330 0.1248 0.1220 0 0.1202 0 0 0.1283 ar11 0 s.e. 0 sigma^2 estimated as 0.000869: log likelihood = 123.57, aic = -231.14 [[3]][[7]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 ar10 0.2496 -0.0818 0.1343 0.0990 0 0 -0.3295 0 0 -0.1043 s.e. 0.1215 0.1260 0.1332 0.1194 0 0 0.1200 0 0 0.1276 ar11 0 s.e. 0 sigma^2 estimated as 0.0008731: log likelihood = 123.44, aic = -232.87 [[3]][[8]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 ar10 ar11 0.2231 0 0.1095 0.1094 0 0 -0.3364 0 0 -0.1035 0 s.e. 0.1144 0 0.1280 0.1189 0 0 0.1199 0 0 0.1279 0 sigma^2 estimated as 0.0008791: log likelihood = 123.23, aic = -234.45 [[3]][[9]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 ar10 ar11 0.2277 0 0.1484 0.1088 0 0 -0.3566 0 0 0 0 s.e. 0.1158 0 0.1194 0.1195 0 0 0.1181 0 0 0 0 sigma^2 estimated as 0.0008906: log likelihood = 122.9, aic = -235.8 [[3]][[10]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, fixed = last.arma$next.vector, method = "ML") Coefficients: ar1 ar2 ar3 ar4 ar5 ar6 ar7 ar8 ar9 ar10 ar11 0.2425 0 0.1737 0 0 0 -0.3440 0 0 0 0 s.e. 0.1150 0 0.1167 0 0 0 0.1177 0 0 0 0 sigma^2 estimated as 0.0009034: log likelihood = 122.49, aic = -236.98 [[3]][[11]] NULL $aic [1] -223.7441 -225.6783 -227.5356 -229.2813 -231.1351 -232.8722 -234.4525 [8] -235.8047 -236.9835 -236.8248 Warning messages: 1: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 2: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 3: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 4: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 5: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 6: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 7: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 8: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 9: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE > postscript(file="/var/www/html/rcomp/tmp/1wft41260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > resid <- arimaSelectplot(selection) > dev.off() null device 1 > resid Time Series: Start = 1 End = 60 Frequency = 1 [1] 0.0014815990 -0.0223525555 -0.0202992593 -0.0080674174 0.0015991607 [6] -0.0291452534 -0.0329364679 -0.0033366217 -0.0254861402 0.0497012447 [11] 0.0062320586 -0.0746660288 0.0559102995 0.0709247306 0.0428508273 [16] 0.0454447998 -0.0435426446 0.0023604162 -0.0192669820 -0.0029162450 [21] -0.0365482603 0.0333808813 0.0171463724 0.0210531851 -0.0478054611 [26] -0.0128104041 -0.0290250345 -0.0028154856 -0.0272625359 0.0160688805 [31] 0.0005581634 -0.0380828909 -0.0231399328 -0.0129384215 0.0312104474 [36] -0.0456870937 -0.0144831424 0.0146018864 0.0019283961 -0.0158263429 [41] -0.0049151464 0.0187266182 -0.0620239217 -0.0216980188 -0.0002081412 [46] 0.0300438094 -0.0287099592 -0.0007565990 0.0258593640 0.0056729015 [51] -0.0096614340 -0.0331705513 0.0204728985 0.0406750564 0.0135945568 [56] 0.0260379830 -0.0259741612 0.0120347626 0.0130151890 -0.0410565948 > postscript(file="/var/www/html/rcomp/tmp/26yxq1260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(resid,length(resid)/2, main='Residual Autocorrelation Function') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/32l6a1260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(resid,length(resid)/2, main='Residual Partial Autocorrelation Function') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4h64y1260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > cpgram(resid, main='Residual Cumulative Periodogram') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/517w01260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(resid, main='Residual Histogram', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6q9211260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/7nexv1260535254.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(resid, main='Residual Normal Q-Q Plot') > qqline(resid) > dev.off() null device 1 > ncols <- length(selection[[1]][1,]) > nrows <- length(selection[[2]][,1])-1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'ARIMA Parameter Estimation and Backward Selection', ncols+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Iteration', header=TRUE) > for (i in 1:ncols) { + a<-table.element(a,names(selection[[3]][[1]]$coef)[i],header=TRUE) + } > a<-table.row.end(a) > for (j in 1:nrows) { + a<-table.row.start(a) + mydum <- 'Estimates (' + mydum <- paste(mydum,j) + mydum <- paste(mydum,')') + a<-table.element(a,mydum, header=TRUE) + for (i in 1:ncols) { + a<-table.element(a,round(selection[[1]][j,i],4)) + } + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'(p-val)', header=TRUE) + for (i in 1:ncols) { + mydum <- '(' + mydum <- paste(mydum,round(selection[[2]][j,i],4),sep='') + mydum <- paste(mydum,')') + a<-table.element(a,mydum) + } + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/8f7l61260535254.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Estimated ARIMA Residuals', 1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Value', 1,TRUE) > a<-table.row.end(a) > for (i in (par4*par5+par3):length(resid)) { + a<-table.row.start(a) + a<-table.element(a,resid[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/9m4um1260535254.tab") > system("convert tmp/1wft41260535254.ps tmp/1wft41260535254.png") > system("convert tmp/26yxq1260535254.ps tmp/26yxq1260535254.png") > system("convert tmp/32l6a1260535254.ps tmp/32l6a1260535254.png") > system("convert tmp/4h64y1260535254.ps tmp/4h64y1260535254.png") > system("convert tmp/517w01260535254.ps tmp/517w01260535254.png") > system("convert tmp/6q9211260535254.ps tmp/6q9211260535254.png") > system("convert tmp/7nexv1260535254.ps tmp/7nexv1260535254.png") > > > proc.time() user system elapsed 2.901 1.069 3.795