Standardize column names from data frames, in particular objects returned from model_parameters(), so column names are consistent and the same for any model object.

standardize_names(data, ...)

# S3 method for parameters_model
standardize_names(data, style = c("easystats", "broom"), ...)

Arguments

data

A data frame. Currently, only objects from model_parameters() are accepted.

...

Currently not used.

style

Standardization can either be based on the naming conventions from the easystats project, or on broom's naming scheme.

Value

A data frame, with standardized column names.

Details

This method is in particular useful for package developers or users who use model_parameters() in their own code or functions to retrieve model parameters for further processing. As model_parameters() returns a data frame with varying column names (depending on the input), accessing the required information is probably not quite straightforward. In such cases, standardize_names() can be used to get consistent, i.e. always the same column names, no matter what kind of model was used in model_parameters().

For style = "broom", column names are renamed to match broom's naming scheme, i.e. Parameter is renamed to term, Coefficient becomes estimate and so on.

Examples

library(parameters) model <- lm(mpg ~ wt + cyl, data = mtcars) mp <- model_parameters(model) as.data.frame(mp)
#> Parameter Coefficient SE CI_low CI_high t df_error #> 1 (Intercept) 39.686261 1.7149840 36.178725 43.1937976 23.140893 29 #> 2 wt -3.190972 0.7569065 -4.739020 -1.6429245 -4.215808 29 #> 3 cyl -1.507795 0.4146883 -2.355928 -0.6596622 -3.635972 29 #> p #> 1 3.043182e-20 #> 2 2.220200e-04 #> 3 1.064282e-03
standardize_names(mp)
#> Parameter Coefficient SE CI_low CI_high Statistic df #> 1 (Intercept) 39.686261 1.7149840 36.178725 43.1937976 23.140893 29 #> 2 wt -3.190972 0.7569065 -4.739020 -1.6429245 -4.215808 29 #> 3 cyl -1.507795 0.4146883 -2.355928 -0.6596622 -3.635972 29 #> p #> 1 3.043182e-20 #> 2 2.220200e-04 #> 3 1.064282e-03
standardize_names(mp, style = "broom")
#> term estimate std.error conf.low conf.high statistic df.error #> 1 (Intercept) 39.686261 1.7149840 36.178725 43.1937976 23.140893 29 #> 2 wt -3.190972 0.7569065 -4.739020 -1.6429245 -4.215808 29 #> 3 cyl -1.507795 0.4146883 -2.355928 -0.6596622 -3.635972 29 #> p.value #> 1 3.043182e-20 #> 2 2.220200e-04 #> 3 1.064282e-03