Is there any possible way to get 95% CI for regression coefficients from the robust regression, as implemented in MASS::rlm?
# libraries needed
library(MASS)
library(stats)
library(datasets)
# running robust regression
(x <-
MASS::rlm(formula = scale(Sepal.Length) ~ scale(Sepal.Width),
data = iris))
#> Call:
#> rlm(formula = scale(Sepal.Length) ~ scale(Sepal.Width), data = iris)
#> Converged in 5 iterations
#>
#> Coefficients:
#> (Intercept) scale(Sepal.Width)
#> -0.03728607 -0.14343268
#>
#> Degrees of freedom: 150 total; 148 residual
#> Scale estimate: 1.06
# getting confidence interval for the regression coefficient
stats::confint(object = x,
parm = "scale(Sepal.Width)",
level = 0.95)
#> 2.5 % 97.5 %
#> scale(Sepal.Width) NA NA
Explicitly calling confint.default
seems to provide good results, like this:
confint.default(object = x, parm = "scale(Sepal.Width)", level = 0.95)
# 2.5 % 97.5 %
#scale(Sepal.Width) -0.3058138 0.01894847
confint
uses method confint.lm
when it is passed x
because x
is of class lm
(as well as rlm
). Calling confint.default
explicitly avoids this. These two functions only differ in one line of code, as shown below:
fac <- qt(a, object$df.residual)
fac <- qnorm(a)
The issue is that x$df.residual
is NA
and, consequently, qt(a, object$df.residual)
produces an NA
whereas qnorm(a)
doesn't have this problem.