Parameters from Generalized Additive (Mixed) Models
Source:R/methods_cgam.R
model_parameters.cgam.Rd
Extract and compute indices and measures to describe parameters of generalized additive models (GAM(M)s).
Usage
# S3 method for class 'cgam'
model_parameters(
model,
ci = 0.95,
ci_method = "residual",
bootstrap = FALSE,
iterations = 1000,
standardize = NULL,
exponentiate = FALSE,
p_adjust = NULL,
keep = NULL,
drop = NULL,
verbose = TRUE,
...
)
Arguments
- model
A gam/gamm model.
- ci
Confidence Interval (CI) level. Default to
0.95
(95%
).- ci_method
Method for computing degrees of freedom for confidence intervals (CI) and the related p-values. Allowed are following options (which vary depending on the model class):
"residual"
,"normal"
,"likelihood"
,"satterthwaite"
,"kenward"
,"wald"
,"profile"
,"boot"
,"uniroot"
,"ml1"
,"betwithin"
,"hdi"
,"quantile"
,"ci"
,"eti"
,"si"
,"bci"
, or"bcai"
. See section Confidence intervals and approximation of degrees of freedom inmodel_parameters()
for further details. Whenci_method=NULL
, in most cases"wald"
is used then.- bootstrap
Should estimates be based on bootstrapped model? If
TRUE
, then arguments of Bayesian regressions apply (see alsobootstrap_parameters()
).- iterations
The number of bootstrap replicates. This only apply in the case of bootstrapped frequentist models.
- standardize
The method used for standardizing the parameters. Can be
NULL
(default; no standardization),"refit"
(for re-fitting the model on standardized data) or one of"basic"
,"posthoc"
,"smart"
,"pseudo"
. See 'Details' instandardize_parameters()
. Importantly:The
"refit"
method does not standardize categorical predictors (i.e. factors), which may be a different behaviour compared to other R packages (such as lm.beta) or other software packages (like SPSS). to mimic such behaviours, either usestandardize="basic"
or standardize the data withdatawizard::standardize(force=TRUE)
before fitting the model.For mixed models, when using methods other than
"refit"
, only the fixed effects will be standardized.Robust estimation (i.e.,
vcov
set to a value other thanNULL
) of standardized parameters only works whenstandardize="refit"
.
- 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
exponentiate = TRUE
for models with log-transformed response values. For models with a log-transformed response variable, whenexponentiate = TRUE
, a one-unit increase in the predictor is associated with multiplying the outcome by that predictor's coefficient. Note: Delta-method standard errors are also computed (by multiplying the standard errors by the transformed coefficients). This is to mimic behaviour of other software packages, such as Stata, but these standard errors poorly estimate uncertainty for the transformed coefficient. The transformed confidence interval more clearly captures this uncertainty. Forcompare_parameters()
,exponentiate = "nongaussian"
will only exponentiate coefficients from non-Gaussian families.- p_adjust
Character vector, if not
NULL
, indicates the method to adjust p-values. Seestats::p.adjust()
for details. Further possible adjustment methods are"tukey"
,"scheffe"
,"sidak"
and"none"
to explicitly disable adjustment foremmGrid
objects (from emmeans).- keep
Character containing a regular expression pattern that describes the parameters that should be included (for
keep
) or excluded (fordrop
) in the returned data frame.keep
may also be a named list of regular expressions. All non-matching parameters will be removed from the output. Ifkeep
is a character vector, every parameter name in the "Parameter" column that matches the regular expression inkeep
will be selected from the returned data frame (and vice versa, all parameter names matchingdrop
will be excluded). Furthermore, ifkeep
has more than one element, these will be merged with anOR
operator into a regular expression pattern like this:"(one|two|three)"
. Ifkeep
is a named list of regular expression patterns, the names of the list-element should equal the column name where selection should be applied. This is useful for model objects wheremodel_parameters()
returns multiple columns with parameter components, like inmodel_parameters.lavaan()
. Note that the regular expression pattern should match the parameter names as they are stored in the returned data frame, which can be different from how they are printed. Inspect the$Parameter
column of the parameters table to get the exact parameter names.- drop
See
keep
.- verbose
Toggle warnings and messages.
- ...
Arguments passed to or from other methods. For instance, when
bootstrap = TRUE
, arguments liketype
orparallel
are passed down tobootstrap_model()
.Further non-documented arguments are:
digits
,p_digits
,ci_digits
andfooter_digits
to set the number of digits for the output.groups
can be used to group coefficients. These arguments will be passed to the print-method, or can directly be used inprint()
, see documentation inprint.parameters_model()
.If
s_value = TRUE
, the p-value will be replaced by the S-value in the output (cf. Rafi and Greenland 2020).pd
adds an additional column with the probability of direction (seebayestestR::p_direction()
for details). Furthermore, see 'Examples' for this function.For developers, whose interest mainly is to get a "tidy" data frame of model summaries, it is recommended to set
pretty_names = FALSE
to speed up computation of the summary table.
Details
The reporting of degrees of freedom for the spline terms
slightly differs from the output of summary(model)
, for example in the
case of mgcv::gam()
. The estimated degrees of freedom, column
edf
in the summary-output, is named df
in the returned data
frame, while the column df_error
in the returned data frame refers to
the residual degrees of freedom that are returned by df.residual()
.
Hence, the values in the the column df_error
differ from the column
Ref.df
from the summary, which is intentional, as these reference
degrees of freedom “is not very interpretable”
(web).
See also
insight::standardize_names()
to rename
columns into a consistent, standardized naming scheme.
Examples
library(parameters)
if (require("mgcv")) {
dat <- gamSim(1, n = 400, dist = "normal", scale = 2)
model <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
model_parameters(model)
}
#> Loading required package: mgcv
#> Loading required package: nlme
#>
#> Attaching package: ‘nlme’
#> The following object is masked from ‘package:lme4’:
#>
#> lmList
#> This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.
#>
#> Attaching package: ‘mgcv’
#> The following object is masked from ‘package:mclust’:
#>
#> mvn
#> Gu & Wahba 4 term additive model
#> # Fixed Effects
#>
#> Parameter | Coefficient | SE | 95% CI | t(383.03) | p
#> --------------------------------------------------------------------
#> (Intercept) | 7.90 | 0.09 | [7.72, 8.09] | 83.78 | < .001
#>
#> # Smooth Terms
#>
#> Parameter | F | df | p
#> -----------------------------------------
#> Smooth term (x0) | 17.65 | 3.10 | < .001
#> Smooth term (x1) | 101.86 | 3.68 | < .001
#> Smooth term (x2) | 98.39 | 7.97 | < .001
#> Smooth term (x3) | 0.56 | 1.22 | 0.421