honest_lm() fits a regular stats::lm() model and adds an honest_lm
class. Familiar methods such as summary(), anova(), and broom methods can
then use more cautious defaults.
Usage
honest_lm(formula, data, ..., p_values = c("honest", "hide", "warn", "show"))Arguments
- formula, data, ...
Passed to
stats::lm().- p_values
How p-values should be handled by honest methods. The default
"honest"shows simple p-values and usesNAfor rows that are easy to misread."hide"suppresses p-value columns where possible."show"includes them."warn"includes them and may warn about contrast interpretation.
Examples
fit <- honest_lm(mpg ~ wt + factor(cyl), data = mtcars)
summary(fit)
#>
#> Call:
#> lm(formula = mpg ~ wt + factor(cyl), data = mtcars)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -4.5890 -1.2357 -0.5159 1.3845 5.7915
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 33.9908 1.8878 18.006 NA
#> wt -3.2056 0.7539 -4.252 0.000213 ***
#> factor(cyl)6 -4.2556 1.3861 -3.070 NA
#> factor(cyl)8 -6.0709 1.6523 -3.674 NA
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Categorical predictors:
#> factor(cyl): 3 levels; reference level = 4
#>
#> Notes:
#> * Intercept p-values are hidden because they usually test whether the expected response is zero at the reference condition. Use intercept_p_value = TRUE if you really want them.
#> * When present, p-values are shown for continuous predictors and two-level categorical predictors.
#> * P-values for multi-level categorical coefficient rows are hidden by default because those rows compare levels to a reference level, not whether the overall predictor matters.
#> * For post-hoc comparisons among factor levels, consider estimated marginal means, e.g. emmeans::emmeans() and pairs(). See https://rvlenth.github.io/emmeans/.
#>
#> Residual standard error: 2.557 on 28 degrees of freedom
#> Multiple R-squared: 0.8374, Adjusted R-squared: 0.82
#> F-statistic: 48.08 on 3 and 28 DF (model-level p-value hidden)