【问题标题】:How do I resolve a "Deprecated" warning using the (pool.compare) function when comparing fitted models?在比较拟合模型时,如何使用 (pool.compare) 函数解决“已弃用”警告?
【发布时间】:2021-07-14 00:53:43
【问题描述】:

我有两个模型,我在估算数据集上运行它们以生成汇总估计值。我的理解是,因为这两个模型都运行在数百个估算数据帧中,所以我必须将所有回归模型估计值汇集或基本上“平均”成一个“整体”估计值。以下是我执行的步骤:

#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)

当我使用“summary(pool(..)”函数时,线性和 RCS 模型都会产生“合并”估计值、95% CI 和 p 值。但是,问题是当我运行“pool.比较”函数,我得到一个错误,指出:

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

当线性模型和 RCS 模型之间的“曝光”、“结果”和所有列出的协变量相同时,为什么模型说 fit0 不包含在 fit1 中,我感到很困惑。我在这里缺少一个选项吗?

任何帮助/指导将不胜感激。

附:不幸的是,考虑到估算数据集的大小,我无法提供示例数据切割。如果有任何困惑,请告诉我如何更好地改进我的问题。

【问题讨论】:

    标签: r regression deprecated imputation r-mice


    【解决方案1】:

    正如错误所说,pool.compare 已被弃用。而是使用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
    

    在某些示例中,只有警告,但在其他示例中,它同时给出错误和警告

    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") 
    

    错误可能是因为模型本身,即 rcs 模型,而下面我们正在比较两个线性模型

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

    可重现的例子

    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
    

    【讨论】:

    • 嗨@akrun,非常感谢。我明白了,所以我可以使用一个名为“D1”的函数。您的解决方案完美运行,我现在得到了估计。再次感谢您的帮助!
    • 最后的澄清。那么在使用“D1”函数的情况下,p 值的解释是否仍然与使用 pool.compare 时相同?如果 p 值
    • @Monarch 在文档中不是很清楚。可以查看参考资料here
    猜你喜欢
    • 2012-01-31
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 2017-03-12
    • 2022-09-26
    • 2016-12-07
    • 2012-08-07
    • 1970-01-01
    相关资源
    最近更新 更多