R2MLwiN: Error while obeying batch file: Wrong number of output columns

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
edwardoughton
Posts: 6
Joined: Tue Jun 03, 2014 7:54 am

R2MLwiN: Error while obeying batch file: Wrong number of output columns

Post by edwardoughton »

I'm trying to recreate MCMC Guide 06 with my data by setting up a random slopes model and then storing the residuals for prediction. I keep receiving the following error :

Error while obeying batch file... wrong number of output columns (full screen shot of error message attached).

Here's my code which sets up the data, specifies a variety of models (1-4), before focusing on how it's done in MCMC Guide 06. It's a three level model, with annual repeated broadband speed measurements (yrid), nested within local authorities (laid), nested within regions (rnid).

Data is attached = total.xlsx (sorry, it wouldn't let me upload the .csv!)

Any help would be much appreciated.

Code: Select all

mlwin = c("C:/Program Files (x86)/MLwiN v2.35/i386")
options(MLwiN_path = mlwin)
total<-read.csv("total.csv")
is.num <- sapply(total, is.numeric)
total[is.num] <- lapply(total[is.num], round, 2)
total$year <- total$year.num

## IGLS
(mymodel1 <- runMLwiN(speed ~ 1 + sfbb +  (1| rnid) + (1 | laid) + (1 | yrid), data = total))
## Gibbs (with diffuse priors/gamma priors, as standard) (MCMC)
(mymodel2 <- runMLwiN(speed ~ 1 + sfbb +  (1| rnid) + (1 | laid) + (1 | yrid), estoptions = list(EstM = 1), data = total))
## Diffuse priors (Uniform priors) (MCMC)
(mymodel3 <- runMLwiN(speed ~ 1 + sfbb + (1| rnid) + (1 | laid) + (1 | yrid), estoptions = list(EstM = 1, mcmcMeth = list(priorcode = 0)), data = total))
## slope at level 1 using sfbb (MCMC)
(mymodel4 <- runMLwiN(speed ~ 1 + sfbb +  (1| rnid) +(1 | laid) + (1 + sfbb| yrid), estoptions = list(EstM = 1), data = total))

-------------------
#Follow guide 06
## Choose MCMC algoritm for estimation (IGLS will be used to obtain starting values for MCMC)
(mymodel6 <- runMLwiN(speed ~ 1 + sfbb + rnid + laid + rnid:sfbb + (1 | yrid), estoptions = list(EstM = 1), data = total))

## Define the model Choose IGLS algoritm for estimation Fit the model
(mymodel6.1 <- runMLwiN(speed ~ 1 + sfbb + (1 | rnid) + (1 | laid) + (1  + sfbb| yrid), data = total))

## Choose MCMC algoritm for estimation (IGLS will be used to obtain starting values for MCMC)
(mymodel6.20 <- runMLwiN(speed ~ 1 + sfbb + (1 | rnid) + (1 | laid) + (1  + sfbb| yrid), estoptions = list(EstM = 1, mcmcMeth = list(iterations = 5001), resi.store.levs= 2),data = total))
Attachments
total.xlsx
Not sure why it wouldn't let me attach the .csv file?
(15.04 KiB) Downloaded 498 times
Screenshot 2015-10-01 10.18.02.png
Screenshot 2015-10-01 10.18.02.png (117.37 KiB) Viewed 4850 times
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: R2MLwiN: Error while obeying batch file: Wrong number of output columns

Post by ChrisCharlton »

Thanks for this example, there was a bug in the generated code for extracting the residuals where it didn't take into account that there is always only one residual variable at level-1 for MCMC models. Because of this the fact that you specified complex level-1 variation meant that it was requesting two, which in turn was causing the error in MLwiN. Although you specified resi.store.levs= 2 this only changes whether residual chains are stored at a level (for backward compatibility reasons once you ask for residuals they are returned at all levels). I have now added a fix to the development version and this should be included in the next release of the software. If you need it sooner than this you can install this version with the following commands:

Code: Select all

library(devtools)
install_github("rforge/r2mlwin", subdir="R2MLwiN")
I also note that you mentioned a random slopes model (e.g. http://www.bristol.ac.uk/cmm/media/r2ml ... CGuide06.R), but the example you showed was modelling complex level-1 variation (e.g. mymodel1 in http://www.bristol.ac.uk/cmm/media/r2ml ... CGuide09.R) instead.
edwardoughton
Posts: 6
Joined: Tue Jun 03, 2014 7:54 am

Re: R2MLwiN: Error while obeying batch file: Wrong number of output columns

Post by edwardoughton »

Dear Chris,

That appears to have done it - thanks!

Also, I appreciate you pointing out the difference between this complex 1 variance model and the random slopes model. Once I've finished my analysis I must cross validate my code on this site.

Ed
Post Reply