Multiple membership model: Error in combchains[, FP.names, drop = FALSE] : subscript out of bounds

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
dimension3
Posts: 8
Joined: Thu Nov 03, 2016 11:17 am

Multiple membership model: Error in combchains[, FP.names, drop = FALSE] : subscript out of bounds

Post by dimension3 »

Hey there,

I want to fit a multiple membership model using the R2MLwiN package and get the error in R:
Error in combchains[, FP.names, drop = FALSE] : subscript out of bounds

The model is estimated correctly in MLwiN as far as I can see (using debugmode = T).
Hence, I get the feeling it has to with the R2MLwiN package itself. I tried to debug it myself but can't find a solution.

The code I specified in R is:

data.wide <- readRDS("mm.rds")
runMLwiN(y ~ 1 + country.x + gov.het.sum + (1 | id.country) + (1 | p) + (1 | id.gov),
estoptions = list(EstM = 1, debugmode = T, mm = list(NA, list(mmvar = list("p", "p2", "p3", "p4"), weights = list("w1", "w2", "w3", "w4")), NA)),
data = data.wide)

Please find the data attached. I had to zip it before uploading it.

I am very grateful for any help!

Kind regards,

Benjamin
Attachments
mm.zip
(65.05 KiB) Downloaded 358 times
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: Multiple membership model: Error in combchains[, FP.names, drop = FALSE] : subscript out of bounds

Post by ChrisCharlton »

This error is due to a mismatch between the parameter names and the chains when bringing the data back to R. In the parameter names any "." characters have been replaced with "_" (e.g. country.x becomes country_x), whereas this is not the case for the parameter chains. This means that R2MLwiN cannot match them back together when loading the results. I will try to determine which naming is correct and fix this for a later version of R2MLwiN, however in the mean time the workaround would be to rename your variables so that they do not contain any "." characters.
dimension3
Posts: 8
Joined: Thu Nov 03, 2016 11:17 am

Re: Multiple membership model: Error in combchains[, FP.names, drop = FALSE] : subscript out of bounds

Post by dimension3 »

Thanks a lot. That indeed solved the problem. For the sake of completeness, this code works:
data.wide <- readRDS("mm.rds")
runMLwiN(y ~ 1 + country_x + gov_het_sum + (1 | id_country) + (1 | p) + (1 | id_gov),
estoptions = list(EstM = 1, debugmode = T, mm = list(NA, list(mmvar = list("p", "p2", "p3", "p4"), weights = list("w1", "w2", "w3", "w4")), NA)),
data = data.wide)
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: Multiple membership model: Error in combchains[, FP.names, drop = FALSE] : subscript out of bounds

Post by ChrisCharlton »

Thanks for confirming this. I have added it to the list of known bugs:
http://www.bristol.ac.uk/cmm/software/r ... nbugs.html
Post Reply