amices / mice

Multivariate Imputation by Chained Equations
https://amices.org/mice/
GNU General Public License v2.0
444 stars 107 forks source link

D1 function returns NA df2 and p value #443

Closed lumiereljy closed 2 years ago

lumiereljy commented 2 years ago

I'm comparing two models, one with two variables var1 and var2, and the other one is the nested model with only one variable var1 using D1(). However, it gives me NA for both df2 and p value. Does anyone know why this happened and how I could possibly overcome this issue? I am attaching the code and test result below. There are 88 cases in total. Thank you in advance for any suggestions!

ordinal.with <- list()
for (i in 1:5){
  mod <- list(polr(y ~ 
    var1 + var2 , data=dff[[i]]))
  ordinal.with <- c(ordinal.with, mod)
}
fit.with <- as.mira(ordinal.with)

ordinal.without <- list()
for (i in 1:5){
  mod <- list(polr(y ~ 
    var1, data=dff[[i]]))
  ordinal.without <- c(ordinal.without, mod)
}
  fit.without <- as.mira(ordinal.without)

D1(fit.with, fit.without)
test<chr> | statistic<dbl> | df1<dbl> | df2<dbl> | dfcom<dbl> | p.value<dbl> | riv<dbl>
1 ~~ 2    | 0.6537879      | 1        | NaN      | 83         | NaN          | 0
gerkovink commented 2 years ago

D1() expects the output to be generated by a call to with.mids() - see the help. You bypass that expectation and create your own with output. If I were you, I'd create a mids object with imp <- as.mids() and then pass the inference pooling over to e.g. with(imp, polr(y ~ var1 + var2)). See if that fixes your issue.

Other than that, I'd need a reprex to be of more help.

stefvanbuuren commented 2 years ago

Closing due to inactivity