gpt4 book ai didi

r - 用于稳健回归的 sjPlot?

转载 作者:行者123 更新时间:2023-12-02 03:12:33 24 4
gpt4 key购买 nike

有人知道 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",置信区间起作用

最佳答案

我觉得不可能。 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 的信息。但我认为这个值(value)不可信。如果你想绘制像 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

关于r - 用于稳健回归的 sjPlot?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39060754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com