Repository navigation
Replies: 2 comments 2 replies
|
I have the same issue! Suspect it's a bug! |
0 replies
|
Multilevel imputation can indeed be tricky, but there is no way of helping you (or determining whether it is a bug) without a reprex. If you are unsure how to write a reprex, please see here: https://reprex.tidyverse.org/articles/reprex-dos-and-donts.html |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Dear Prof.Van Buuren, thank you very much for your book.
I am glad I have a chance to ask you a question here about it as well!
I have the following problem. It happened that I have only one level-2 variable and it has several missing values(it was an online survey from two organizations and there was a trouble with the data collection, so I am am sure the missing data is MCAR). I try to use 2lonly.pmm to fill in the gaps. I specify this variable as a -2 in pred:
suppressWarnings(suppressMessages( ini <- mice(df, maxit = 0) ))pred <- ini$predpred [,"school"] <- -2When running the mice function it gives me the following error:
Error in check.cluster(data, predictorMatrix) : Convert cluster variable school to integer by as.integer()I switched the organization variable to an integer and the error message then became as the following:
Error in .imputation.level2(y = y, ry = ry, x = x, type = type, wy = wy, : No class variableI added additional variable "city", where both organizations are at, and specified it as a cluster variable in the pred. It didn't help, same error.
Then I tried to specify the full pred matrix in excel and read it from a csv file as a matrix, the error changed to:
Error in predictorMatrix[h, ] : subgroup out of boundsI consulted your book again and saw the following passage:
"It is conceptually straightforward to extend imputations to higher levels (Yucel 2008). If there are two levels, combine all level-2 predictors with an aggregate (e.g., the cluster means) of the level-1 predictors and the level-1 outcomes. Once we have this, we may choose suitable methods from Chapter 3 to impute the missing level-2 variables in the usual way. No new issues arise."
Is there a way to fix my problem? Or, given the above, is there maybe a way to not treat this variable as a cluster variable and just impute it with logreg in mice since it's the only one variable? Do you mean by aggregate to compute mean values or cluster variables?
Thank you in advance for reading the post and have a great day ahead!
Best Regards,
Yulia
All reactions