【问题标题】:sjPlot for robust regression?sjPlot 用于稳健回归?
【发布时间】:2016-12-27 21:30:53
【问题描述】:

是否有人知道 sjp.Int 是否适用于稳健回归?基本绘图工作,但置信区间不起作用? 错误=

Error in seq.default(from = best$lmin, to = best$lmax, by = best$lstep) : 
 'from' must be of length 1
 In addition: Warning messages:
  1: In min(intdf$conf.low, na.rm = T) :
  no non-missing arguments to min; returning Inf
  2: In max(intdf$conf.high, na.rm = T) :
  no non-missing arguments to max; returning -Inf

我使用的命令是:

fname = rlm(Y ~ X1+X2+X3+X4*X5, data=mydata)
sjp.int(fname, type="eff", show.ci=TRUE)

对于 type="cond",置信区间确实有效

【问题讨论】:

    标签: r plot regression sjplot


    【解决方案1】:

    我认为这是不可能的。 sjp.int(type="eff") 使用effects::allEffects() 来计算CI 等。但是这个函数不计算rlm.model 的CI(返回NAs),所以sjp.int(rlm.model, type="eff", show.ci=TRUE) 不起作用。 (参考代码;summary(effects::allEffects(fname, KR=F)))。

    [已编辑]

    (sjp.int(fname, type="eff")) 返回data.list,它有关于se 的信息。但我不认为这个价值是可信的。如果你想画sjp.int这样的图形,我觉得你最好用predict(rlm.model),因为predict有处理rlm.model的方法。

    我的例子;

    library(ggplot2)
    
    df <- with(iris, data.frame(Y = Petal.Length,     # example data
                                X1 = Sepal.Length, X2 = Sepal.Width, X3 = Petal.Width))
    
    fname <- rlm(Y ~ X1 + X2 * X3, df)
    pred.df <- with(df, data.frame(X1 = mean(X1),
                                   X2 = c( min(X2), max(X2) ),
                                   X3 = rep( seq( min(X3), max(X3), 0.1), each=2 )))
    
    pred.df <- cbind(pred.df, predict(fname, pred.df, interval="confidence"))
    pred.df$X2 <- as.factor(pred.df$X2)
    
    ggplot(pred.df, aes(x=X3, y=fit, group=X2, colour=X2, fill=X2)) + geom_line() + 
      geom_ribbon(aes(ymin = lwr, ymax = upr, colour=NULL), alpha=0.2)
    

    【讨论】:

    • 我已经检查并比较了predict.rlm()effects::allEffects()的结果,您提到的效果包返回的标准误差确实与预测功能略有不同。预测函数的置信区间不是效果包标准误差的 1.96 倍,而是 ~1.79 倍......(因此 rlm 估计的标准误差应该与效果返回的值略有不同 -包)
    猜你喜欢
    • 2012-11-28
    • 2018-03-04
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 2017-03-25
    • 1970-01-01
    • 2018-01-13
    • 2016-02-18
    相关资源
    最近更新 更多