How do I resolve a "Deprecated" warning using the (pool.compare) function when comparing fitted models?

Viewed 147

I have two models which I am running across an imputed dataset in order to produce pooled estimates. My understanding is that because both models are ran through hundreds of imputed data frames, I have to pool or essentially "average out" all the regression model estimates into one "overall" estimate. Below are the steps I did:

#1 IMPUTE MASTER DATASET
     imputed_data <- mice(master, m=20, maxit=50, seed=5798713)

#2 RUN LINEAR MODEL 
     model.linear <- with(imputed_data, lm(outcome~exposure+age+gender+weight))
     summary(pool(model.linear))

#3 RUN NON-LINEAR RESTRICTED CUBIC SPLINE (3-KNOT) MODEL
     model.rcs <- with(imputed_data, lm(outcome~rcs(exposure,3)+age+gender+weight))
     summary(pool(model.rcs))

#4 COMPARE BOTH MODELS USING POOL.COMPARE FUNCTION
     pool.compare(model.rcs, model.linear)

Both linear and RCS models produce "pooled" estimates, 95% CI's, and p-values once I use the "summary(pool(..)" function. However, the issue is that when I run the "pool.compare" function, I get an error that states:

Error: Model 'fit0' not contained in 'fit1'
In addition: Warning message:
'pool.compare' is deprecated.
Use 'D1' instead.
See help("Deprecated") 

I'm confused as to why the model says fit0 is not contained in fit1 when the "exposure", "outcome", and all the covariates listed are the same between the linear and RCS models. Is there an option that I'm missing here?

Any help/guidance would be very appreciated.

P.S. I am unfortunately unable to provide a sample datacut considering how large the imputed dataset is. Let me know how I can better improve my question if there's any confusion.

1 Answers

As the error says, pool.compare is deprecated. Instead use D1

library(mice)
library(rms)
D1(model.rcs, model.linear)
#    test statistic df1      df2 dfcom    p.value      riv
# 1 ~~ 2  6.248565   2 8.635754    20 0.02098072 0.449098

In some examples, there is only warning, but in others, it give both Error and warning

pool.compare(model.rcs, model.linear)
#Error: Model 'fit0' not contained in 'fit1'
#In addition: Warning message:
#  'pool.compare' is deprecated.
#Use 'D1' instead.
#See help("Deprecated") 

The error would be because of the model itself i.e. rcs model while below we are comparing two linear models

imp <- mice(nhanes)
model.linear <- with(imp, lm(age ~ bmi + hyp + chl))
model.rcs <- with(imp, lm(age ~ rcs(bmi, 3) + hyp + chl))

Reproducible example

imp <- mice(nhanes2, print=FALSE, m=50, seed=00219)
fit0 <- with(data=imp,expr=lm(bmi~age+hyp))
fit1 <- with(data=imp,expr=lm(bmi~age+hyp+chl))
stat <- pool.compare(fit1, fit0)
#Warning message:
#'pool.compare' is deprecated.
#Use 'D1' instead.
#See help("Deprecated") 

stat <- D1(fit1, fit0)
stat
#   test statistic df1     df2 dfcom    p.value       riv
# 1 ~~ 2  7.606026   1 16.2182    20 0.01387548 0.3281893
Related