Skip to content

Adding statistic and p-values to rq class objects #404

Description

@IndrajeetPatil

The tidy.rq function currently doesn't output either the statistic (t-value) or p.value for the quantile regression, but this can be easily obtained using summary.rq(). It will be nice if this is included in the tidy output to be consistent with output from other regression models. The se = "nid" part can be absorbed in ..., so if anybody wants to use a differerent method to compute standard standard errors, they can use this argument.

# loading libraries and needed data
library(broom)
library(quantreg)
data(engel)

# specifying quantile regression model
rq_model <- quantreg::rq(
  formula = foodexp ~ income,
  tau = 0.5,
  data = engel
)

# getting tidy summary
broom::tidy(x = rq_model)
#>          term   estimate   conf.low   conf.high tau
#> 1 (Intercept) 81.4822474 47.0904023 135.1883939 0.5
#> 2      income  0.5601806  0.4803301   0.6127786 0.5

# getting summary with summary.rq
coef(summary(object = rq_model, se = "nid"))
#>                  Value  Std. Error   t value     Pr(>|t|)
#> (Intercept) 81.4822474 19.25066025  4.232699 3.322875e-05
#> income       0.5601806  0.02827721 19.810319 0.000000e+00

Created on 2018-06-25 by the reprex package (v0.2.0).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions