R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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.2998 + ,1.3146 + ,1.3225 + ,1.3321 + ,1.3339 + ,1.3496 + ,1.3647 + ,1.3674 + ,1.3647 + ,1.3481 + ,1.3612 + ,1.3626 + ,1.3711 + ,1.37 + ,1.377 + ,1.3945 + ,1.3917 + ,1.4084 + ,1.4244 + ,1.4014 + ,1.4018 + ,1.3926 + ,1.3857 + ,1.3857 + ,1.3803 + ,1.3912 + ,1.4031 + ,1.3934 + ,1.4016 + ,1.3861 + ,1.3859 + ,1.3896 + ,1.4089 + ,1.4101 + ,1.3958 + ,1.3833 + ,1.3936 + ,1.3874 + ,1.397 + ,1.3856 + ,1.378 + ,1.3705 + ,1.3726 + ,1.3648 + ,1.3611 + ,1.346 + ,1.3477 + ,1.3412 + ,1.3323 + ,1.3364 + ,1.312 + ,1.3074 + ,1.306 + ,1.3078 + ,1.2989 + ,1.285 + ,1.2801 + ,1.2725 + ,1.2715 + ,1.2697 + ,1.2744 + ,1.2874 + ,1.2834 + ,1.2818 + ,1.28 + ,1.268 + ,1.27 + ,1.2713 + ,1.2693 + ,1.2613 + ,1.2611 + ,1.2704 + ,1.2711 + ,1.2836 + ,1.288 + ,1.286 + ,1.282 + ,1.2799 + ,1.279 + ,1.3016 + ,1.3133 + ,1.3253 + ,1.3176 + ,1.3184 + ,1.3206 + ,1.3221 + ,1.3073 + ,1.3028 + ,1.3069 + ,1.2992 + ,1.3033 + ,1.2931 + ,1.2897 + ,1.285 + ,1.2817 + ,1.2844 + ,1.2957 + ,1.3 + ,1.2828 + ,1.2703 + ,1.2569 + ,1.2572 + ,1.2637 + ,1.266 + ,1.2567 + ,1.2579 + ,1.2531 + ,1.2548 + ,1.2328 + ,1.2271 + ,1.2198 + ,1.2339 + ,1.2294 + ,1.2262 + ,1.2271 + ,1.2258 + ,1.2391 + ,1.2372 + ,1.2363 + ,1.2277 + ,1.2258 + ,1.2249 + ,1.2127 + ,1.2045 + ,1.201 + ,1.1942 + ,1.1959 + ,1.206 + ,1.2268 + ,1.2218 + ,1.2155 + ,1.2307 + ,1.2384 + ,1.2255 + ,1.2309 + ,1.2223 + ,1.236 + ,1.2497 + ,1.2334 + ,1.227 + ,1.2428 + ,1.2349 + ,1.2492 + ,1.2587 + ,1.2686 + ,1.2698 + ,1.2969 + ,1.2746 + ,1.2727 + ,1.2924 + ,1.3089 + ,1.3238 + ,1.3315 + ,1.3256 + ,1.3245 + ,1.329 + ,1.3321 + ,1.3311 + ,1.3339 + ,1.3373 + ,1.3486 + ,1.3432 + ,1.3535 + ,1.3544 + ,1.3615 + ,1.3583 + ,1.3585 + ,1.3384 + ,1.3296 + ,1.334 + ,1.3396 + ,1.3468 + ,1.3479 + ,1.3482 + ,1.3471 + ,1.3353 + ,1.3356 + ,1.3338 + ,1.3519 + ,1.3471 + ,1.3548 + ,1.366 + ,1.3756 + ,1.3723 + ,1.3705 + ,1.3765 + ,1.3657 + ,1.361 + ,1.3557 + ,1.3662 + ,1.3582 + ,1.3668 + ,1.3641 + ,1.3548 + ,1.3525 + ,1.357 + ,1.3489 + ,1.3547 + ,1.3577 + ,1.3626 + ,1.3519 + ,1.3567 + ,1.3726 + ,1.3649 + ,1.3607 + ,1.3572 + ,1.3718 + ,1.374 + ,1.376 + ,1.3675 + ,1.3691 + ,1.3847 + ,1.3984 + ,1.3937 + ,1.3913 + ,1.3966 + ,1.3999 + ,1.4072 + ,1.4085 + ,1.4151 + ,1.4135 + ,1.4064 + ,1.4132 + ,1.4279 + ,1.4369 + ,1.4374 + ,1.4486 + ,1.4563 + ,1.4481 + ,1.4528 + ,1.4273 + ,1.4304 + ,1.435 + ,1.4442 + ,1.4389 + ,1.4406 + ,1.4338 + ,1.4433 + ,1.4405 + ,1.4398 + ,1.4276 + ,1.4279 + ,1.4368 + ,1.4337 + ,1.4343 + ,1.456 + ,1.4541 + ,1.4647 + ,1.4757 + ,1.473 + ,1.4768 + ,1.4774 + ,1.4787 + ,1.5068 + ,1.512 + ,1.509 + ,1.5074 + ,1.5023 + ,1.4918 + ,1.5071 + ,1.5083 + ,1.4969 + ,1.4968 + ,1.4815 + ,1.4863 + ,1.4957 + ,1.4875 + ,1.4965 + ,1.4868 + ,1.4922 + ,1.5037 + ,1.4966 + ,1.4984 + ,1.4862 + ,1.4867 + ,1.4761 + ,1.4658 + ,1.4772 + ,1.48 + ,1.4788 + ,1.4785 + ,1.4874 + ,1.5019 + ,1.502 + ,1.5 + ,1.4921 + ,1.4971 + ,1.4918 + ,1.4869 + ,1.4864 + ,1.4881 + ,1.4864 + ,1.4765 + ,1.475 + ,1.4763 + ,1.4694 + ,1.4722 + ,1.4616 + ,1.4537 + ,1.4539 + ,1.4643 + ,1.4549 + ,1.465 + ,1.467 + ,1.4768 + ,1.4783 + ,1.478 + ,1.4658 + ,1.4705 + ,1.4712 + ,1.4671 + ,1.4611 + ,1.4561 + ,1.4594 + ,1.4545 + ,1.4522 + ,1.4473 + ,1.433 + ,1.4262 + ,1.4335 + ,1.422 + ,1.4314 + ,1.4272 + ,1.4364 + ,1.4268 + ,1.427 + ,1.4324 + ,1.4323 + ,1.433 + ,1.4243 + ,1.4112 + ,1.4101 + ,1.4072 + ,1.4294 + ,1.4293 + ,1.417 + ,1.4166 + ,1.4202 + ,1.4357 + ,1.437 + ,1.441 + ,1.4384 + ,1.4303 + ,1.4138 + ,1.4053 + ,1.4104 + ,1.4229 + ,1.4269 + ,1.4227 + ,1.4229 + ,1.4191 + ,1.4223 + ,1.4217 + ,1.409 + ,1.413 + ,1.4089 + ,1.3991 + ,1.3975 + ,1.3901 + ,1.399 + ,1.3901 + ,1.4019 + ,1.3897 + ,1.4009 + ,1.4049 + ,1.4096 + ,1.4134 + ,1.4058 + ,1.4096 + ,1.394 + ,1.4029 + ,1.3978 + ,1.3858 + ,1.3932 + ,1.392 + ,1.384 + ,1.389 + ,1.385 + ,1.4004 + ,1.3969 + ,1.4102 + ,1.3959 + ,1.3866 + ,1.4177 + ,1.4095 + ,1.4207 + ,1.4238 + ,1.422 + ,1.4098 + ,1.3856 + ,1.3901 + ,1.3908 + ,1.401 + ,1.3972 + ,1.3771 + ,1.369 + ,1.3612 + ,1.3494 + ,1.3518 + ,1.3563 + ,1.3623 + ,1.3683 + ,1.3574 + ,1.3425 + ,1.3363 + ,1.3322 + ,1.3403 + ,1.3223 + ,1.3275 + ,1.3266 + ,1.2992 + ,1.3125 + ,1.3232 + ,1.305 + ,1.2947 + ,1.2932 + ,1.2966 + ,1.3058 + ,1.3196 + ,1.3173 + ,1.3276 + ,1.3273 + ,1.3231 + ,1.3255 + ,1.3496 + ,1.3425 + ,1.3392 + ,1.3246 + ,1.3308 + ,1.3193 + ,1.3295 + ,1.3607 + ,1.3494 + ,1.3507 + ,1.3558 + ,1.3549 + ,1.3671 + ,1.313 + ,1.2942 + ,1.3042 + ,1.2905 + ,1.2782 + ,1.2786 + ,1.2783 + ,1.2565 + ,1.2658 + ,1.2555 + ,1.2555 + ,1.2615 + ,1.2596 + ,1.2644 + ,1.2782 + ,1.2795 + ,1.2763 + ,1.2798 + ,1.2591 + ,1.2705 + ,1.2596 + ,1.2634 + ,1.2765 + ,1.2823 + ,1.2833 + ,1.2938 + ,1.2967 + ,1.3008 + ,1.2796 + ,1.2829 + ,1.2818 + ,1.2849 + ,1.276 + ,1.2816 + ,1.3111 + ,1.326 + ,1.3174 + ,1.299 + ,1.2795 + ,1.2984 + ,1.291 + ,1.293 + ,1.3182 + ,1.327 + ,1.3085 + ,1.3173 + ,1.3262 + ,1.3394 + ,1.3684 + ,1.3617 + ,1.3595 + ,1.3332 + ,1.3582 + ,1.3866) > par9 = '1' > par8 = '2' > par7 = '1' > par6 = '3' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1.9' > par1 = 'FALSE' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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 <- 5 #seasonal period > par6 <- as.numeric(par6) #degree (p) of the non-seasonal AR(p) polynomial > 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.387128967 -0.03624405 -0.02995389 -0.39784915 0.08895780 0.05305832 [2,] 0.403947777 -0.03613977 -0.02896229 -0.41465459 0.09754450 0.05225121 [3,] 0.511412160 -0.04509744 0.00000000 -0.52163398 0.09623435 0.05296610 [4,] -0.003486957 0.00000000 0.00000000 -0.00477251 0.08923699 0.04392788 [5,] 0.000000000 0.00000000 0.00000000 0.00000000 0.09203729 0.00000000 [6,] NA NA NA NA NA NA [7,] NA NA NA NA NA NA [8,] NA NA NA NA NA NA [9,] NA NA NA NA NA NA [10,] NA NA NA NA NA NA [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 [,7] [1,] 0.007832828 [2,] 0.000000000 [3,] 0.000000000 [4,] 0.000000000 [5,] 0.000000000 [6,] NA [7,] NA [8,] NA [9,] NA [10,] NA [11,] NA [12,] NA [13,] NA [14,] NA [[2]] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 0.34479 0.46362 0.56794 0.33030 0.96093 0.76910 0.99656 [2,] 0.31062 0.46714 0.58082 0.29615 0.04553 0.27098 NA [3,] 0.11864 0.34715 NA 0.10916 0.04574 0.26408 NA [4,] NaN NA NA NaN 0.05316 0.34900 NA [5,] NA NA NA NA 0.04595 NA NA [6,] NA NA NA NA NA NA NA [7,] NA NA NA NA NA NA NA [8,] NA NA NA NA NA NA NA [9,] NA NA NA NA NA NA NA [10,] NA NA NA NA NA NA NA [11,] NA NA NA NA NA NA NA [12,] NA NA NA NA NA NA NA [13,] NA NA NA NA NA NA NA [14,] NA NA NA NA NA NA NA [[3]] [[3]][[1]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, method = "ML") Coefficients: ar1 ar2 ar3 ma1 sar1 sar2 sma1 0.3871 -0.0362 -0.0300 -0.3978 0.0890 0.0531 0.0078 s.e. 0.4094 0.0494 0.0524 0.4083 1.8152 0.1806 1.8179 sigma^2 estimated as 0.0006492: log likelihood = 1102.92, aic = -2189.84 [[3]][[2]] Call: arima(x = series, order = order, seasonal = seasonal, include.mean = include.mean, method = "ML") Coefficients: ar1 ar2 ar3 ma1 sar1 sar2 sma1 0.3871 -0.0362 -0.0300 -0.3978 0.0890 0.0531 0.0078 s.e. 0.4094 0.0494 0.0524 0.4083 1.8152 0.1806 1.8179 sigma^2 estimated as 0.0006492: log likelihood = 1102.92, aic = -2189.84 [[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 ma1 sar1 sar2 sma1 0.4039 -0.0361 -0.0290 -0.4147 0.0975 0.0523 0 s.e. 0.3980 0.0497 0.0524 0.3965 0.0487 0.0474 0 sigma^2 estimated as 0.0006492: log likelihood = 1102.92, aic = -2191.84 [[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 ma1 sar1 sar2 sma1 0.5114 -0.0451 0 -0.5216 0.0962 0.0530 0 s.e. 0.3271 0.0479 0 0.3250 0.0480 0.0474 0 sigma^2 estimated as 0.0006496: log likelihood = 1102.77, aic = -2193.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 ma1 sar1 sar2 sma1 -0.0035 0 0 -0.0048 0.0892 0.0439 0 s.e. NaN 0 0 NaN 0.0460 0.0469 0 sigma^2 estimated as 0.0006517: log likelihood = 1102, aic = -2194.01 [[3]][[6]] NULL [[3]][[7]] NULL $aic [1] -2189.837 -2191.837 -2193.537 -2194.009 -2199.088 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 sqrt(diag(arima.out$var.coef)) : NaNs produced 4: In arima(series, order = order, seasonal = seasonal, include.mean = include.mean, : some AR parameters were fixed: setting transform.pars = FALSE 5: In sqrt(diag(x$var.coef)) : NaNs produced > postscript(file="/var/www/html/freestat/rcomp/tmp/18a291292276912.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > resid <- arimaSelectplot(selection) Error in if (pval[j, i] < 0.01) symb = "green" else if ((pval[j, i] < : missing value where TRUE/FALSE needed Calls: arimaSelectplot Execution halted