可以使用summary()函数来提取分位数回归的结果中变量的p值、SE和Coefficient。

例如,假设我们进行了一个分位数回归模型:

library(quantreg)
data("engel")
fit <- rq(foodexp ~ income, tau = 0.5, data = engel)
summary(fit)

输出结果如下:

Call: rq(formula = foodexp ~ income, tau = 0.5, data = engel)

tau: [1] 0.5

Coefficients:
            coefficients lower bd  upper bd 
(Intercept)  298.4142    226.8522 344.7728
income        0.5215     0.4749   0.5798 

Degrees of freedom: 235 total; 233 residual
Residual standard error: 41.31

可以看到,输出结果中包含了变量的Coefficient、p值、SE,以及其他一些统计信息。我们可以使用summary()函数来提取这些信息:

# 提取变量的Coefficient
coef(summary(fit))

# 提取变量的p值
coef(summary(fit))[,4]

# 提取变量的SE
coef(summary(fit))[,2]

其中,coef(summary(fit))返回一个矩阵,其中每一行表示一个变量的Coefficient、SE、t值和p值。因此,我们可以使用[,4]来提取p值,使用[,2]来提取SE

R语言进行分位数回归 如何提取结果中变量的p值以及SE和Coefficient

原文地址: https://www.cveoy.top/t/topic/fWSL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录