sjPlot进行稳健回归?

时间:2016-08-21 04:06:07

标签: r plot regression sjplot

是否有人知道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",置信区间确实有效

1 个答案:

答案 0 :(得分: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)

enter image description here

相关问题