Alternate title: Model matrix and set of coefficients show different numbers of variables
I am using the mice package for R to do some analyses. I wanted to compare two models (held in mira objects) using pool.compare()
, but I keep getting the following error:
Error in model.matrix(formula, data) %*% coefs : non-conformable arguments
The binary operator %*%
indicates matrix multiplication in R.
The expression model.matrix(formula, data)
produces "The design matrix for a regression-like model with the specified formula and data" (from the R Documentation for model.matrix {stats}).
In the error message, coefs
is drawn from est1$qbar
, where est1
is a mipo object, and the qbar
element is "The average of complete data estimates. The multiple imputation estimate." (from the documentation for mipo-class {mice}).
In my case
est1$qbar
is a numeric vector of length 36data
is a data.frame with 918 observations of 82 variablesformula
is class 'formula' containing the formula for my modelmodel.matrix(formula, data)
is a matrix with dimension 918 x 48.
How can I resolve/prevent this error?