Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
Usage
# S3 method for class 'rqs'
tidy(x, se.type = "rank", conf.int = FALSE, conf.level = 0.95, ...)
Arguments
- x
An
rqs
object returned fromquantreg::rq()
.- se.type
Character specifying the method to use to calculate standard errors. Passed to
quantreg::summary.rq()
se
argument. Defaults to"rank"
.- conf.int
Logical indicating whether or not to include a confidence interval in the tidied output. Defaults to
FALSE
.- conf.level
The confidence level to use for the confidence interval if
conf.int = TRUE
. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.- ...
Additional arguments passed to
quantreg::summary.rqs()
Details
If se.type = "rank"
confidence intervals are calculated by
summary.rq
. When only a single predictor is included in the model,
no confidence intervals are calculated and the confidence limits are
set to NA.
See also
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
Value
A tibble::tibble()
with columns:
- conf.high
Upper bound on the confidence interval for the estimate.
- conf.low
Lower bound on the confidence interval for the estimate.
- estimate
The estimated value of the regression term.
- p.value
The two-sided p-value associated with the observed statistic.
- statistic
The value of a T-statistic to use in a hypothesis that the regression term is non-zero.
- std.error
The standard error of the regression term.
- term
The name of the regression term.
- quantile
Linear conditional quantile.
Examples
# load modeling library and data
library(quantreg)
data(stackloss)
# median (l1) regression fit for the stackloss data.
mod1 <- rq(stack.loss ~ stack.x, .5)
# weighted sample median
mod2 <- rq(rnorm(50) ~ 1, weights = runif(50))
# summarize model fit with tidiers
tidy(mod1)
#> # A tibble: 4 × 5
#> term estimate conf.low conf.high tau
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) -39.7 -53.8 -24.5 0.5
#> 2 stack.xAir.Flow 0.832 0.509 1.17 0.5
#> 3 stack.xWater.Temp 0.574 0.272 3.04 0.5
#> 4 stack.xAcid.Conc. -0.0609 -0.278 0.0153 0.5
glance(mod1)
#> # A tibble: 1 × 5
#> tau logLik AIC BIC df.residual
#> <dbl> <logLik> <dbl> <dbl> <int>
#> 1 0.5 -50.15272 108. 112. 17
augment(mod1)
#> # A tibble: 21 × 5
#> stack.loss stack.x[,"Air.Flow"] [,"Water.Temp"] .resid .fitted .tau
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 42 80 27 5.06e+ 0 36.9 0.5
#> 2 37 80 27 -1.42e-14 37 0.5
#> 3 37 75 25 5.43e+ 0 31.6 0.5
#> 4 28 62 24 7.63e+ 0 20.4 0.5
#> 5 18 62 22 -1.22e+ 0 19.2 0.5
#> 6 18 62 23 -1.79e+ 0 19.8 0.5
#> 7 19 62 24 -1.00e+ 0 20 0.5
#> 8 20 62 24 -7.11e-15 20 0.5
#> 9 15 58 23 -1.46e+ 0 16.5 0.5
#> 10 14 58 18 -2.03e- 2 14.0 0.5
#> # ℹ 11 more rows
#> # ℹ 1 more variable: stack.x[3] <dbl>
tidy(mod2)
#> # A tibble: 1 × 5
#> term estimate conf.low conf.high tau
#> <chr> <dbl> <lgl> <lgl> <dbl>
#> 1 (Intercept) 0.0744 NA NA 0.5
glance(mod2)
#> # A tibble: 1 × 5
#> tau logLik AIC BIC df.residual
#> <dbl> <logLik> <dbl> <dbl> <int>
#> 1 0.5 -72.9869 148. 150. 49
augment(mod2)
#> # A tibble: 50 × 5
#> `rnorm(50)` `(weights)` .resid .fitted .tau
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1.25 0.192 1.18 0.0744 0.5
#> 2 0.458 0.321 0.383 0.0744 0.5
#> 3 0.765 0.0297 0.691 0.0744 0.5
#> 4 0.392 0.870 0.317 0.0744 0.5
#> 5 -0.547 0.647 -0.622 0.0744 0.5
#> 6 -0.468 0.319 -0.542 0.0744 0.5
#> 7 -1.11 0.293 -1.18 0.0744 0.5
#> 8 0.786 0.669 0.711 0.0744 0.5
#> 9 -0.648 0.408 -0.722 0.0744 0.5
#> 10 1.07 0.664 1.00 0.0744 0.5
#> # ℹ 40 more rows
# varying tau to generate an rqs object
mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5))
tidy(mod3)
#> # A tibble: 8 × 5
#> term estimate conf.low conf.high tau
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) -3.6 e+ 1 -59.0 -7.84 0.25
#> 2 stack.xAir.Flow 5.00e- 1 0.229 0.970 0.25
#> 3 stack.xWater.Temp 1.00e+ 0 0.286 2.26 0.25
#> 4 stack.xAcid.Conc. -4.58e-16 -0.643 0.0861 0.25
#> 5 (Intercept) -3.97e+ 1 -53.8 -24.5 0.5
#> 6 stack.xAir.Flow 8.32e- 1 0.509 1.17 0.5
#> 7 stack.xWater.Temp 5.74e- 1 0.272 3.04 0.5
#> 8 stack.xAcid.Conc. -6.09e- 2 -0.278 0.0153 0.5
augment(mod3)
#> # A tibble: 42 × 5
#> stack.loss stack.x[,"Air.Flow"] [,"Water.Temp"] .tau .resid .fitted
#> <dbl> <dbl> <dbl> <chr> <dbl> <dbl>
#> 1 42 80 27 0.25 1.10e+ 1 31.0
#> 2 42 80 27 0.5 5.06e+ 0 36.9
#> 3 37 80 27 0.25 6.00e+ 0 31.0
#> 4 37 80 27 0.5 -1.42e-14 37
#> 5 37 75 25 0.25 1.05e+ 1 26.5
#> 6 37 75 25 0.5 5.43e+ 0 31.6
#> 7 28 62 24 0.25 9.00e+ 0 19
#> 8 28 62 24 0.5 7.63e+ 0 20.4
#> 9 18 62 22 0.25 1.00e+ 0 17.0
#> 10 18 62 22 0.5 -1.22e+ 0 19.2
#> # ℹ 32 more rows
#> # ℹ 1 more variable: stack.x[3] <dbl>
# glance cannot handle rqs objects like `mod3`--use a purrr
# `map`-based workflow instead