summary.lm_()
is a method for objects of class lm_
, extending the standard
summary.lm()
functionality.
It returns a summary object similar to summary.lm
, but includes additional
metadata such as variable labels (if available), making the output more
informative for reporting and interpretation.
This method is part of the experimental lm_()
modeling framework.
# S3 method for class 'lm_'
summary(object, ...)
An object of class lm_
, typically returned by lm_()
.
Additional arguments passed to stats::summary.lm()
.
An object of class summary.lm_
, which inherits from summary.lm
and
includes an optional labels
component if available in the original model.
data(iris)
# Add labels to variables
attr(iris$Sepal.Length, "label") <- "Sepal Length (cm)"
attr(iris$Petal.Length, "label") <- "Petal Length (cm)"
attr(iris$Species, "label") <- "Iris Species"
# Fit model using lm_()
model <- lm_(iris, formula = Petal.Length ~ Sepal.Length + Species)
# Get summary with labels
summary_model <- summary(model)
summary_model
#>
#> Call:
#> stats::lm(formula = formula, data = data)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.76390 -0.17875 0.00716 0.17461 0.79954
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -1.70234 0.23013 -7.397 1.01e-11 ***
#> Sepal.Length 0.63211 0.04527 13.962 < 2e-16 ***
#> Speciesversicolor 2.21014 0.07047 31.362 < 2e-16 ***
#> Speciesvirginica 3.09000 0.09123 33.870 < 2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 0.2826 on 146 degrees of freedom
#> Multiple R-squared: 0.9749, Adjusted R-squared: 0.9744
#> F-statistic: 1890 on 3 and 146 DF, p-value: < 2.2e-16
#>
# Access labels
summary_model$labels
#> Petal.Length Sepal.Length
#> "Petal Length (cm)" "Sepal Length (cm)"
#> Species Speciessetosa
#> "Iris Species" "Iris Species [setosa]"
#> Speciesversicolor Speciesvirginica
#> "Iris Species [versicolor]" "Iris Species [virginica]"