user6121484 - 1 year ago 69

R Question

Is there someone who know if sjp.Int works for robust regressions? Basic plotting works, but the confidence intervals do not work?

Error=

`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

Command I used was:

`fname = rlm(Y ~ X1+X2+X3+X4*X5, data=mydata)`

sjp.int(fname, type="eff", show.ci=TRUE)

For type="cond", the confidence intervals do work

Answer Source

I think it is impossible. `sjp.int(type="eff")`

uses `effects::allEffects()`

to calculate CI etc. But this function doesn't calculate `rlm.model`

's CI (returns `NAs`

), so `sjp.int(rlm.model, type="eff", show.ci=TRUE)`

doesn't work. (Reference code; `summary(effects::allEffects(fname, KR=F))`

).

`(sjp.int(fname, type="eff"))`

returns `data.list`

and it have information about `se`

. But I don't think the value is credible. If you want to draw a graph like `sjp.int`

, I think it would be better for you to use `predict(rlm.model)`

because `predict`

have a method of treating `rlm.model`

.

my example;

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