简体   繁体   English

"获得稳健回归系数的置信区间 (MASS::rlm)"

[英]Getting confidence intervals for robust regression coefficient (MASS::rlm)

Is there any possible way to get 95% CI for regression coefficients from the robust regression, as implemented in MASS::rlm?是否有任何可能的方法可以从稳健回归中获得 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

Explicitly calling confint.default seems to provide good results, like this: 显式调用confint.default似乎可以提供良好的结果,如下所示:

confint.default(object = x, parm = "scale(Sepal.Width)", level = 0.95)

#                        2.5 %     97.5 %
#scale(Sepal.Width) -0.3058138 0.01894847

Edit 编辑

confint uses method confint.lm when it is passed x because x is of class lm (as well as rlm ). confint使用方法confint.lm当它传递x因为x是类的lm (以及rlm )。 Calling confint.default explicitly avoids this. 调用confint.default明确避免这种情况。 These two functions only differ in one line of code, as shown below: 这两个函数仅在一行代码中有所不同,如下所示:

confint.lm confint.lm

fac <- qt(a, object$df.residual)

confint.default confint.default

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. 问题是x$df.residualNA ,因此qt(a, object$df.residual)产生NAqnorm(a)没有这个问题。

Late to the party, but note that CIs from the normal distribution will have lower than expected coverage for small sample sizes.迟到了,但请注意,对于小样本量,正态分布的 CI 的覆盖率将低于预期。

The residual degrees of freedom for the rlm object can be gotten from, rlm 对象的剩余自由度可以从,

summary(x)$df[2]  # see code for MASS:::summary.rlm

To write your own confint method for rlm results, assign the df to the df.residual slot, and then call confint.lm:要为 rlm 结果编写自己的 confint 方法,请将 df 分配给 df.residual 槽,然后调用 confint.lm:

confint.rlm <- function(object, ...){
  object$df.residual <- MASS:::summary.rlm(object)$df[2]
  confint.lm(object, ...)
}

Now confint behaves as expected, and is also based on Student's t:现在 confint 的行为符合预期,并且还基于学生的 t:

confint(x)
                        2.5 %     97.5 %
(Intercept)        -0.2004593 0.12588715
scale(Sepal.Width) -0.3071526 0.02028719

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用置信区间绘制回归系数 - Plot regression coefficient with confidence intervals R 用稳健的线性回归模型 (rlm) 绘制置信区间线 - R plot confidence interval lines with a robust linear regression model (rlm) 处理MASS:使用MM估计器多次拟合鲁棒回归时出现rlm错误 - Handling MASS: rlm error while fitting robust regression multiple times using MM-estimator R 中的 Function 计算线性回归的异方差稳健置信区间 - Function in R that computes heteroskedasticity-robust confidence intervals for a linear regression 具有Newey West标准误差的稳健回归(rlm) - Robust Regression (rlm) with Newey West Standard Errors 岭回归的置信区间 - Confidence intervals for Ridge regression 线性回归:用拟合参数的标准误差相关系数计算置信区间和预测区间 - Linear regression: calculate confidence and prediction intervals with the standard errors of the fitted parameters the correlation coefficient 使用 rlm 计算稳健回归的 r 平方是否合适 - Is it appropriate to calculate r-squared of robust regression using rlm 通过自举获得 glmer 系数置信区间 - Obtaining glmer coefficient confidence intervals via bootstrapping 转换texreg输出中的系数和置信区间 - Transform the coefficient and confidence intervals in texreg output
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM