有没有办法从稳健回归中获得回归系数的95%CI,如在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
答案 0 :(得分:1)
明确调用ERROR: syntax error at or near "character"
LINE 1: ...LTER TABLE user_template ALTER COLUMN "type" character ...
^
似乎可以提供良好的结果,如下所示:
confint.default
confint.default(object = x, parm = "scale(Sepal.Width)", level = 0.95)
# 2.5 % 97.5 %
#scale(Sepal.Width) -0.3058138 0.01894847
在传递confint
时使用方法confint.lm
,因为x
属于类x
(以及lm
)。明确地调用rlm
可以避免这种情况。这两个函数仅在一行代码中有所不同,如下所示:
confint.default
fac <- qt(a, object$df.residual)
问题是fac <- qnorm(a)
是x$df.residual
,因此NA
会产生qt(a, object$df.residual)
,而NA
不会产生此问题。< / p>