Provides a convenient way to extract any kind of model information from common model objects

extract_model_info(model_object = NULL, what = NULL, ...)

Arguments

model_object

A model object for example a linear model object, generalized linear model object, analysis of variance object.

what

character. The attribute you would like to obtain for instance p_value

...

Arguments to other functions e.g. AIC, BIC, deviance etc

Details

This provides a convenient way to extract model information for any kind of model. For linear models, one can extract such attributes as coefficients, p value("p_value"), standard error("std_err"), estimate, t value("t_value"), residuals, aic and other known attributes. For analysis of variance (aov), other attributes like sum squared(ssq), mean squared error(msq), degrees of freedom(df),p_value.

Examples

# perform analysis of variance
data("yields", package="manymodelr")
aov_mod <- fit_model(yields, "weight","height + normal","aov")
extract_model_info(aov_mod, "ssq")
#>              Sum Sq
#> height       0.9721
#> normal       0.0528
#> Residuals   29.6789
extract_model_info(aov_mod, c("ssq","predictors")) 
#> $ssq
#>              Sum Sq
#> height       0.9721
#> normal       0.0528
#> Residuals   29.6789
#> 
#> $predictors
#> [1] "height + normal"
#> 
# linear regression
lm_model <-fit_model(yields, "weight","height","lm")
extract_model_info(lm_model,c("aic","bic"))
#> $aic
#> [1] -671.6655
#> 
#> $bic
#> [1] -656.9423
#> 
## glm
glm_model <- fit_model(yields, "weight","height","glm")
extract_model_info(glm_model,"aic")
#> [1] -671.6655