Page 1 of 1

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

Posted: Thu Nov 03, 2016 11:33 am
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

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

Posted: Thu Nov 03, 2016 1:38 pm
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.

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

Posted: Fri Nov 04, 2016 2:51 pm
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)

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

Posted: Fri Nov 04, 2016 3:30 pm
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