View source: R/compare_parameters.R
compare_parameters | R Documentation |
Compute and extract model parameters of multiple regression
models. See model_parameters()
for further details.
compare_parameters(
...,
ci = 0.95,
effects = "fixed",
component = "conditional",
standardize = NULL,
exponentiate = FALSE,
ci_method = "wald",
p_adjust = NULL,
select = NULL,
column_names = NULL,
pretty_names = TRUE,
coefficient_names = NULL,
keep = NULL,
drop = NULL,
include_reference = FALSE,
groups = NULL,
verbose = TRUE
)
compare_models(
...,
ci = 0.95,
effects = "fixed",
component = "conditional",
standardize = NULL,
exponentiate = FALSE,
ci_method = "wald",
p_adjust = NULL,
select = NULL,
column_names = NULL,
pretty_names = TRUE,
coefficient_names = NULL,
keep = NULL,
drop = NULL,
include_reference = FALSE,
groups = NULL,
verbose = TRUE
)
... |
One or more regression model objects, or objects returned by
|
ci |
Confidence Interval (CI) level. Default to |
effects |
Should parameters for fixed effects ( |
component |
Model component for which parameters should be shown. See
documentation for related model class in |
standardize |
The method used for standardizing the parameters. Can be
|
exponentiate |
Logical, indicating whether or not to exponentiate the
coefficients (and related confidence intervals). This is typical for
logistic regression, or more generally speaking, for models with log or
logit links. It is also recommended to use |
ci_method |
Method for computing degrees of freedom for p-values
and confidence intervals (CI). See documentation for related model class
in |
p_adjust |
Character vector, if not |
select |
Determines which columns and and which layout columns are printed. There are three options for this argument:
There are two pre-defined options for selecting columns:
It is possible to create multiple columns as well. A If
- `"ci"`: Estimates and confidence intervals, no asterisks for p-values. This is equivalent to `select = "{estimate} ({ci})"`. - `"se"`: Estimates and standard errors, no asterisks for p-values. This is equivalent to `select = "{estimate} ({se})"`. - `"ci_p"`: Estimates, confidence intervals and asterisks for p-values. This is equivalent to `select = "{estimate}{stars} ({ci})"`. - `"se_p"`: Estimates, standard errors and asterisks for p-values. This is equivalent to `select = "{estimate}{stars} ({se})"`.. - `"ci_p2"`: Estimates, confidence intervals and numeric p-values, in two columns. This is equivalent to `select = "{estimate} ({ci})|{p}"`. - `"se_p2"`: Estimate, standard errors and numeric p-values, in two columns. This is equivalent to `select = "{estimate} ({se})|{p}"`. For |
column_names |
Character vector with strings that should be used as
column headers. Must be of same length as number of models in |
pretty_names |
Can be |
coefficient_names |
Character vector with strings that should be used
as column headers for the coefficient column. Must be of same length as
number of models in |
keep |
Character containing a regular expression pattern that
describes the parameters that should be included (for |
drop |
See |
include_reference |
Logical, if |
groups |
Named list, can be used to group parameters in the printed output.
List elements may either be character vectors that match the name of those
parameters that belong to one group, or list elements can be row numbers
of those parameter rows that should belong to one group. The names of the
list elements will be used as group names, which will be inserted as "header
row". A possible use case might be to emphasize focal predictors and control
variables, see 'Examples'. Parameters will be re-ordered according to the
order used in |
verbose |
Toggle warnings and messages. |
This function is in an early stage and does not yet cope with more complex models, and probably does not yet properly render all model components. It should also be noted that when including models with interaction terms, not only do the values of the parameters change, but so does their meaning (from main effects, to simple slopes), thereby making such comparisons hard. Therefore, you should not use this function to compare models with interaction terms with models without interaction terms.
A data frame of indices related to the model's parameters.
data(iris)
lm1 <- lm(Sepal.Length ~ Species, data = iris)
lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris)
compare_parameters(lm1, lm2)
# custom style
compare_parameters(lm1, lm2, select = "{estimate}{stars} ({se})")
# custom style, in HTML
result <- compare_parameters(lm1, lm2, select = "{estimate}<br>({se})|{p}")
print_html(result)
data(mtcars)
m1 <- lm(mpg ~ wt, data = mtcars)
m2 <- glm(vs ~ wt + cyl, data = mtcars, family = "binomial")
compare_parameters(m1, m2)
# exponentiate coefficients, but not for lm
compare_parameters(m1, m2, exponentiate = "nongaussian")
# change column names
compare_parameters("linear model" = m1, "logistic reg." = m2)
compare_parameters(m1, m2, column_names = c("linear model", "logistic reg."))
# or as list
compare_parameters(list(m1, m2))
compare_parameters(list("linear model" = m1, "logistic reg." = m2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.