This collection of functions is useful for extracting estimates and statistics from a fitted
model. They are particularly useful when estimating many models, like when bootstrapping
confidence intervals. Each function can be used with an already fitted model as an lm object,
or a formula and associated data can be passed to it. All of these assume the comparison is the
empty model.
Usage
b0(object, data = NULL)
b1(object, data = NULL)
b(object, data = NULL, all = FALSE, predictor = character())
f(object, data = NULL, all = FALSE, predictor = character(), type = 3)
pre(object, data = NULL, all = FALSE, predictor = character(), type = 3)
p(object, data = NULL, all = FALSE, predictor = character(), type = 3)Arguments
- object
- data
If
objectis a formula, the data to fit the formula to as adata.frame.- all
If
TRUE, return a named list of all related terms (e.g. all F-values).The name for the full model value is the name of the function (e.g. "f"), and the names for the constituent terms are the term names prefixed by the function name (e.g. "f_a:b" for the F-value of thea:binteraction term).- predictor
Filter the output down to just the statistics for these terms (e.g. "hp" to just get the statistics for that term in the model). This argument is flexible: you can pass a character vector of terms (
c("hp", "hp:cyl")), a one-sided formula (~hp), or a list of formulae (c(~hp, ~hp:cyl)).- type
The type of sums of squares to calculate (see
generate_models()). Defaults to the widely used TypeIIISS.
Details
b0: The intercept from the full model.b1: The slope b1 from the full model.b: The coefficients from the full model.f: The F value from the full model.pre: The Proportional Reduction in Error for the full model.p: The p-value from the full model.sse: The SS Error (SS Residual) from the model.ssm: The SS Model (SS Regression) for the full model.ssr: Alias for SSM.
fVal() and PRE() are older names for f() and pre(). They are kept
for backward compatibility and behave identically to the newer functions.
References
Judd, C. M., McClelland, G. H., & Ryan, C. S. (2017). Data Analysis: A Model Comparison Approach to Regression, ANOVA, and Beyond (3rd ed.). New York: Routledge. ISBN:879-1138819832
Examples
supernova(lm(mpg ~ disp, data = mtcars))
#> Analysis of Variance Table (Type III SS)
#> Model: mpg ~ disp
#>
#> SS df MS F PRE p
#> ----- --------------- | -------- -- ------- ------ ----- -----
#> Model (error reduced) | 808.888 1 808.888 76.513 .7183 .0000
#> Error (from model) | 317.159 30 10.572
#> ----- --------------- | -------- -- ------- ------ ----- -----
#> Total (empty model) | 1126.047 31 36.324
change_p_decimals <- supernova(lm(mpg ~ disp, data = mtcars))
print(change_p_decimals, pcut = 8)
#> Analysis of Variance Table (Type III SS)
#> Model: mpg ~ disp
#>
#> SS df MS F PRE p
#> ----- --------------- | -------- -- ------- ------ ----- ---------
#> Model (error reduced) | 808.888 1 808.888 76.513 .7183 .00000000
#> Error (from model) | 317.159 30 10.572
#> ----- --------------- | -------- -- ------- ------ ----- ---------
#> Total (empty model) | 1126.047 31 36.324