diff --git a/NAMESPACE b/NAMESPACE index 1a88b6dbe..7db274736 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -659,7 +659,7 @@ S3method(get_parameters,glimML) S3method(get_parameters,glmgee) S3method(get_parameters,glmm) S3method(get_parameters,glmmTMB) -S3method(get_parameters,glmmadmb) +S3method(get_parameters,glmmTMBadmb) S3method(get_parameters,glmx) S3method(get_parameters,hglm) S3method(get_parameters,htest) diff --git a/R/find_parameters_bayesian.R b/R/find_parameters_bayesian.R index 5b0cd7bf8..e8e542fc2 100644 --- a/R/find_parameters_bayesian.R +++ b/R/find_parameters_bayesian.R @@ -8,8 +8,6 @@ #' #' @param parameters Regular expression pattern that describes the parameters that #' should be returned. -#' @param effects Should parameters for fixed effects, random effects -#' or both be returned? Only applies to mixed models. May be abbreviated. #' @param ... Currently not used. #' @inheritParams find_parameters #' @inheritParams find_parameters.betamfx diff --git a/R/find_parameters_mfx.R b/R/find_parameters_mfx.R index 087350a7d..95112ad6b 100644 --- a/R/find_parameters_mfx.R +++ b/R/find_parameters_mfx.R @@ -2,27 +2,31 @@ #' @name find_parameters.betamfx #' #' @description Returns the names of model parameters, like they typically -#' appear in the `summary()` output. +#' appear in the `summary()` output. #' -#' @param component Which type of parameters to return, such as parameters for the -#' conditional model, the zero-inflated part of the model, the dispersion -#' term, the instrumental variables or marginal effects be returned? Applies -#' to models with zero-inflated and/or dispersion formula, or to models with -#' instrumental variables (so called fixed-effects regressions), or models -#' with marginal effects from **mfx**. May be abbreviated. Note that the -#' *conditional* component is also called *count* or *mean* -#' component, depending on the model. There are three convenient shortcuts: -#' `component = "all"` returns all possible parameters. -#' If `component = "location"`, location parameters such as `conditional`, -#' `zero_inflated`, `smooth_terms`, or `instruments` are returned -#' (everything that are fixed or random effects - depending on the `effects` -#' argument - but no auxiliary parameters). For `component = "distributional"` -#' (or `"auxiliary"`), components like `sigma`, `dispersion`, -#' `beta` or `precision` (and other auxiliary parameters) are returned. +#' @param component Which type of parameters to return, such as parameters for +#' the conditional model, the zero-inflated part of the model, the dispersion +#' term, the instrumental variables or marginal effects be returned? Applies to +#' models with zero-inflated and/or dispersion formula, or to models with +#' instrumental variables (so called fixed-effects regressions), or models with +#' marginal effects from **mfx**. See details in section _Model Components_ .May +#' be abbreviated. Note that the *conditional* component also refers to the +#' *count* or *mean* component - names may differ, depending on the modeling +#' package. There are three convenient shortcuts: +#' - `component = "all"` returns all possible parameters. +#' - If `component = "location"`, location parameters such as `conditional`, +#' `zero_inflated`, `smooth_terms`, or `instruments` are returned (everything +#' that are fixed or random effects - depending on the `effects` argument - +#' but no auxiliary parameters). +#' - For `component = "distributional"` (or `"auxiliary"`), components like +#' `sigma`, `dispersion`, `beta` or `precision` (and other auxiliary +#' parameters) are returned. #' @param ... Currently not used. #' @inheritParams find_parameters #' @inheritParams find_predictors #' +#' @inheritSection find_predictors Model components +#' #' @return A list of parameter names. The returned list may have following #' elements: #' diff --git a/R/find_parameters_mixed.R b/R/find_parameters_mixed.R index 90ab41622..307f1ec3e 100644 --- a/R/find_parameters_mixed.R +++ b/R/find_parameters_mixed.R @@ -15,13 +15,16 @@ #' are fixed or random effects - depending on the `effects` argument - #' but no auxiliary parameters). For `component = "distributional"` (or #' `"auxiliary"`), components like `sigma` or `dispersion` (and -#' other auxiliary parameters) are returned. +#' other auxiliary parameters) are returned. See section _Model Component_ +#' for details. #' @param ... Currently not used. #' @inheritParams find_parameters #' @inheritParams find_parameters.betamfx #' @inheritParams find_parameters.BGGM #' @inheritParams find_predictors #' +#' @inheritSection find_predictors Model components +#' #' @return A list of parameter names. The returned list may have following #' elements, usually returned based on the combination of the `effects` and #' `component` arguments: @@ -47,7 +50,10 @@ #' @export find_parameters.glmmTMB <- function(x, effects = "all", component = "all", flatten = FALSE, ...) { effects <- validate_argument(effects, c("all", "fixed", "random")) - component <- validate_argument(component, c("all", "conditional", "zi", "zero_inflated", "dispersion")) + component <- validate_argument( + component, + c("all", "conditional", "zi", "zero_inflated", "dispersion", "location", "distributional", "auxiliary") + ) # installed check_if_installed("lme4") @@ -151,7 +157,10 @@ find_parameters.nlmerMod <- function(x, effects = "all", component = "all", flat #' @export find_parameters.hglm <- function(x, effects = "all", component = "all", flatten = FALSE, ...) { effects <- validate_argument(effects, c("all", "fixed", "random")) - component <- validate_argument(component, c("all", "conditional", "dispersion")) + component <- validate_argument( + component, + c("all", "conditional", "dispersion", "location", "distributional", "auxiliary") + ) fe <- x$fixef re <- x$ranef diff --git a/R/find_parameters_zi.R b/R/find_parameters_zi.R index 32a5178b1..e313c297a 100644 --- a/R/find_parameters_zi.R +++ b/R/find_parameters_zi.R @@ -9,6 +9,8 @@ #' @inheritParams find_parameters.betamfx #' @inheritParams find_predictors #' +#' @inheritSection find_predictors Model components +#' #' @return A list of parameter names. The returned list may have following #' elements: #' diff --git a/R/find_predictors.R b/R/find_predictors.R index e30d1deb8..49933e715 100644 --- a/R/find_predictors.R +++ b/R/find_predictors.R @@ -7,8 +7,9 @@ #' the original variable names from the data that was used to fit the model. #' #' @param x A fitted model. -#' @param effects Should variables for fixed effects, random effects -#' or both be returned? Only applies to mixed models. May be abbreviated. +#' @param effects Should variables for fixed effects (`"fixed"`), random effects +#' (`"random"`) or both (`"all"`) be returned? Only applies to mixed models. May +#' be abbreviated. #' @param component Indicates which model component should be returned. E.g., #' should all predictor variables, predictor variables for the conditional #' model, the zero-inflated part of the model, the dispersion term or the @@ -49,11 +50,16 @@ #' **Special models** #' #' Some model classes also allow rather uncommon options. These are: -#' - `mhurdle`: `"infrequent_purchase"`, `"ip"`, and `"auxiliary"` -#' - `BGGM`: `"correlation"` and `"intercept"` -#' - `BFBayesFactor`, `glmx`: `"extra"` -#' - `averaging`:`"conditional"` and `"full"` -#' - `mjoint`: `"survival"` +#' - **mhurdle**: `"infrequent_purchase"`, `"ip"`, and `"auxiliary"` +#' - **BGGM**: `"correlation"` and `"intercept"` +#' - **BFBayesFactor**, **glmx**: `"extra"` +#' - **averaging**:`"conditional"` and `"full"` +#' - **mjoint**: `"survival"` +#' - **mfx**: `"precision"`, `"marginal"` +#' +#' For models of class `brmsfit` (package **brms**), `component`, even more +#' options are possible for the `component` argument, which are not all +#' documented in detail here. #' #' @section Parameters, Variables, Predictors and Terms: #' There are four functions that return information about the variables in a diff --git a/R/get_parameters.R b/R/get_parameters.R index 208497c04..9df1d9433 100644 --- a/R/get_parameters.R +++ b/R/get_parameters.R @@ -8,7 +8,7 @@ #' - [Estimated marginal means][get_parameters.emmGrid] (**emmeans**) #' - [Generalized additive models][get_parameters.gamm] (**mgcv**, **VGAM**, ...) #' - [Marginal effects models][get_parameters.betamfx] (**mfx**) -#' - [Mixed models][get_parameters.glmm] (**lme4**, **glmmTMB**, **GLMMadaptive**, ...) +#' - [Mixed models][get_parameters.glmmTMB] (**lme4**, **glmmTMB**, **GLMMadaptive**, ...) #' - [Zero-inflated and hurdle models][get_parameters.zeroinfl] (**pscl**, ...) #' - [Models with special components][get_parameters.betareg] (**betareg**, **MuMIn**, ...) #' - [Hypothesis tests][get_parameters.htest] (`htest`) diff --git a/R/get_parameters_bayesian.R b/R/get_parameters_bayesian.R index 604004515..948fa382b 100644 --- a/R/get_parameters_bayesian.R +++ b/R/get_parameters_bayesian.R @@ -46,8 +46,9 @@ #' get_parameters(m) #' @export get_parameters.BGGM <- function(x, - component = c("correlation", "conditional", "intercept", "all"), - summary = FALSE, centrality = "mean", + component = "correlation", + summary = FALSE, + centrality = "mean", ...) { # check_if_installed("BGGM") # @@ -57,7 +58,10 @@ get_parameters.BGGM <- function(x, correlations <- grepl("(.*)--(.*)", colnames(out)) conditional <- !intercepts & !correlations - component <- match.arg(component) + component <- validate_argument( + component, + c("correlation", "conditional", "intercept", "all") + ) out <- switch(component, conditional = out[, conditional, drop = FALSE], correlation = out[, correlations, drop = FALSE], @@ -71,14 +75,13 @@ get_parameters.BGGM <- function(x, } -#' @rdname get_parameters.BGGM #' @export get_parameters.MCMCglmm <- function(x, - effects = c("fixed", "random", "all"), + effects = "fixed", summary = FALSE, centrality = "mean", ...) { - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random", "all")) nF <- x$Fixed$nfl fixed <- as.data.frame(x$Sol[, 1:nF, drop = FALSE]) @@ -103,8 +106,8 @@ get_parameters.MCMCglmm <- function(x, #' @rdname get_parameters.BGGM #' @export get_parameters.BFBayesFactor <- function(x, - effects = c("all", "fixed", "random"), - component = c("all", "extra"), + effects = "all", + component = "all", iterations = 4000, progress = FALSE, verbose = TRUE, @@ -113,8 +116,8 @@ get_parameters.BFBayesFactor <- function(x, ...) { check_if_installed("BayesFactor") - effects <- match.arg(effects) - component <- match.arg(component) + effects <- validate_argument(effects, c("all", "fixed", "random")) + component <- validate_argument(component, c("all", "extra")) bf_type <- .classify_BFBayesFactor(x) # check if valid model was indexed... @@ -178,16 +181,14 @@ get_parameters.BFBayesFactor <- function(x, } - -#' @rdname get_parameters.BGGM #' @export get_parameters.stanmvreg <- function(x, - effects = c("fixed", "random", "all"), + effects = "fixed", parameters = NULL, summary = FALSE, centrality = "mean", ...) { - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random", "all")) elements <- .get_elements(effects, "all") parms <- find_parameters(x, flatten = FALSE, parameters = parameters) @@ -211,7 +212,6 @@ get_parameters.stanmvreg <- function(x, } - #' @rdname get_parameters.BGGM #' @export get_parameters.brmsfit <- function(x, @@ -221,8 +221,11 @@ get_parameters.brmsfit <- function(x, summary = FALSE, centrality = "mean", ...) { - effects <- match.arg(effects, choices = c("all", "fixed", "random")) - component <- match.arg(component, choices = c("all", .all_elements(), "location", "distributional")) + effects <- validate_argument(effects, c("all", "fixed", "random")) + component <- validate_argument( + component, + c("all", .all_elements(), "location", "distributional") + ) if (is_multivariate(x)) { parms <- find_parameters(x, flatten = FALSE, parameters = parameters) @@ -239,18 +242,19 @@ get_parameters.brmsfit <- function(x, } - -#' @rdname get_parameters.BGGM #' @export get_parameters.stanreg <- function(x, - effects = c("fixed", "random", "all"), - component = c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary"), + effects = "fixed", + component = "location", parameters = NULL, summary = FALSE, centrality = "mean", ...) { - effects <- match.arg(effects) - component <- match.arg(component) + effects <- validate_argument(effects, c("fixed", "random", "all")) + component <- validate_argument( + component, + c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary") + ) out <- as.data.frame(x)[.get_parms_data(x, effects, component, parameters)] if (isTRUE(summary)) { @@ -264,7 +268,6 @@ get_parameters.stanreg <- function(x, get_parameters.stanfit <- get_parameters.stanreg - #' @export get_parameters.bcplm <- function(x, parameters = NULL, @@ -282,15 +285,13 @@ get_parameters.bcplm <- function(x, } - -#' @rdname get_parameters.BGGM #' @export get_parameters.bayesx <- function(x, - component = c("conditional", "smooth_terms", "all"), + component = "conditional", summary = FALSE, centrality = "mean", ...) { - component <- match.arg(component) + component <- validate_argument(component, c("conditional", "smooth_terms", "all")) smooth_dat <- data.frame( Parameter = find_parameters(x, component = "smooth_terms", flatten = TRUE), @@ -321,7 +322,6 @@ get_parameters.bayesx <- function(x, } - #' @export get_parameters.mcmc.list <- function(x, parameters = NULL, @@ -339,16 +339,17 @@ get_parameters.mcmc.list <- function(x, } - -#' @rdname get_parameters.BGGM #' @export get_parameters.bamlss <- function(x, - component = c("all", "conditional", "smooth_terms", "location", "distributional", "auxiliary"), + component = "all", parameters = NULL, summary = FALSE, centrality = "mean", ...) { - component <- match.arg(component) + component <- validate_argument( + component, + c("all", "conditional", "smooth_terms", "location", "distributional", "auxiliary") + ) elements <- .get_elements(effects = "all", component) parms <- find_parameters(x, flatten = FALSE, parameters = parameters) @@ -360,7 +361,6 @@ get_parameters.bamlss <- function(x, } - #' @export get_parameters.mcmc <- function(x, parameters = NULL, @@ -375,7 +375,6 @@ get_parameters.mcmc <- function(x, } - #' @export get_parameters.bayesQR <- function(x, parameters = NULL, @@ -392,7 +391,6 @@ get_parameters.bayesQR <- function(x, } - #' @export get_parameters.blrm <- function(x, parameters = NULL, @@ -408,16 +406,14 @@ get_parameters.blrm <- function(x, } - -#' @rdname get_parameters.BGGM #' @export get_parameters.sim.merMod <- function(x, - effects = c("fixed", "random", "all"), + effects = "fixed", parameters = NULL, summary = FALSE, centrality = "mean", ...) { - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random", "all")) fe <- re <- NULL if (effects %in% c("fixed", "all")) fe <- .get_armsim_fixef_parms(x) if (effects %in% c("random", "all")) re <- .get_armsim_ranef_parms(x) @@ -433,8 +429,6 @@ get_parameters.sim.merMod <- function(x, } - -#' @rdname get_parameters.BGGM #' @export get_parameters.sim <- function(x, parameters = NULL, @@ -470,14 +464,12 @@ get_parameters.sim <- function(x, } - .get_bf_posteriors <- function(posteriors, params) { cn <- intersect(colnames(posteriors), params) posteriors[, cn, drop = FALSE] } - .get_parms_data <- function(x, effects, component, parameters = NULL) { elements <- .get_elements(effects, component) unlist(find_parameters(x, effects = "all", component = "all", flatten = FALSE, parameters = parameters)[elements]) @@ -485,8 +477,6 @@ get_parameters.sim <- function(x, - - # use temporarily code from BGGM package, as long as that package is archived on CRAN .bggm_posterior_samples <- function(object, ...) { diff --git a/R/get_parameters_emmeans.R b/R/get_parameters_emmeans.R index a8c1fba42..b95795b39 100644 --- a/R/get_parameters_emmeans.R +++ b/R/get_parameters_emmeans.R @@ -64,7 +64,6 @@ get_parameters.emmGrid <- function(x, summary = FALSE, merge_parameters = FALSE, } -#' @rdname get_parameters.emmGrid #' @export get_parameters.emm_list <- function(x, summary = FALSE, ...) { if (!.is_baysian_emmeans(x) || isTRUE(summary)) { diff --git a/R/get_parameters_mixed.R b/R/get_parameters_mixed.R index 8c2633559..5680aa20e 100644 --- a/R/get_parameters_mixed.R +++ b/R/get_parameters_mixed.R @@ -1,5 +1,5 @@ #' @title Get model parameters from mixed models -#' @name get_parameters.glmm +#' @name get_parameters.glmmTMB #' #' @description Returns the coefficients from a model. #' @@ -19,15 +19,110 @@ #' #' @details In most cases when models either return different "effects" (fixed, #' random) or "components" (conditional, zero-inflated, ...), the arguments -#' `effects` and `component` can be used. +#' `effects` and `component` can be used. See details in the section +#' _Model Components_. #' -#' @examples -#' data(mtcars) -#' m <- lm(mpg ~ wt + cyl + vs, data = mtcars) +#' @examplesIf requireNamespace("glmmTMB", quietly = TRUE) +#' data(Salamanders, package = "glmmTMB") +#' m <- glmmTMB::glmmTMB( +#' count ~ mined + (1 | site), +#' ziformula = ~mined, +#' family = poisson(), +#' data = Salamanders +#' ) #' get_parameters(m) #' @export -get_parameters.glmm <- function(x, effects = c("all", "fixed", "random"), ...) { - effects <- match.arg(effects) +get_parameters.glmmTMB <- function(x, effects = "fixed", component = "all", ...) { + check_if_installed("lme4") + + effects <- validate_argument(effects, c("fixed", "random")) + component <- validate_argument( + component, + c("all", "conditional", "zi", "zero_inflated", "dispersion", "location", "distributional", "auxiliary") # nolint + ) + + if (effects == "fixed") { + l <- compact_list(list( + conditional = lme4::fixef(x)$cond, + zero_inflated = lme4::fixef(x)$zi, + dispersion = lme4::fixef(x)$disp + )) + } else { + l <- compact_list(list( + conditional = lme4::fixef(x)$cond, + random = lme4::ranef(x)$cond, + zero_inflated = lme4::fixef(x)$zi, + zero_inflated_random = lme4::ranef(x)$zi, + dispersion = lme4::fixef(x)$disp, + dispersion_random = lme4::ranef(x)$disp + )) + } + + # ---- fixed effects (conditional model) + + fixed <- data.frame( + Parameter = names(l$conditional), + Estimate = unname(l$conditional), + Component = "conditional", + stringsAsFactors = FALSE + ) + + # ---- fixed effects (zero_inflated model) + + if (object_has_names(l, "zero_inflated")) { + fixedzi <- data.frame( + Parameter = names(l$zero_inflated), + Estimate = unname(l$zero_inflated), + Component = "zero_inflated", + stringsAsFactors = FALSE + ) + } else { + fixedzi <- NULL + } + + # ---- fixed effects (dispersion model) + + if (object_has_names(l, "dispersion")) { + fixeddisp <- data.frame( + Parameter = names(l$dispersion), + Estimate = unname(l$dispersion), + Component = "dispersion", + stringsAsFactors = FALSE + ) + } else { + fixeddisp <- NULL + } + + # ---- build result + + if (effects == "fixed") { + out <- switch(component, + all = rbind(fixed, fixedzi, fixeddisp), + conditional = fixed, + zi = , + zero_inflated = fixedzi, + dispersion = fixeddisp + ) + text_remove_backticks(out) + } else if (effects == "random") { + switch(component, + all = compact_list(list( + random = l$random, + zero_inflated_random = l$zero_inflated_random, + dispersion_random = l$dispersion_random + )), + conditional = l$random, + zi = , + zero_inflated = l$zero_inflated_random, + dispersion_random = l$dispersion_random + ) + } +} + + +#' @export +get_parameters.glmm <- function(x, effects = "all", ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) params <- data.frame( Parameter = names(c(x$beta, x$nu)), @@ -46,13 +141,10 @@ get_parameters.glmm <- function(x, effects = c("all", "fixed", "random"), ...) { } - -#' @rdname get_parameters.glmm #' @export -get_parameters.coxme <- function(x, effects = c("fixed", "random"), ...) { +get_parameters.coxme <- function(x, effects = "fixed", ...) { check_if_installed("lme4") - - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { l <- list(conditional = lme4::fixef(x)) @@ -77,10 +169,9 @@ get_parameters.coxme <- function(x, effects = c("fixed", "random"), ...) { } - #' @export -get_parameters.wbm <- function(x, effects = c("fixed", "random"), ...) { - effects <- match.arg(effects) +get_parameters.wbm <- function(x, effects = "fixed", ...) { + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { s <- summary(x) @@ -128,17 +219,12 @@ get_parameters.wbgee <- function(x, ...) { } - -#' @rdname get_parameters.glmm #' @export -get_parameters.nlmerMod <- function(x, - effects = c("fixed", "random"), - component = c("all", "conditional", "nonlinear"), - ...) { +get_parameters.nlmerMod <- function(x, effects = "fixed", component = "all", ...) { check_if_installed("lme4") - effects <- match.arg(effects) - component <- match.arg(component) + effects <- validate_argument(effects, c("fixed", "random")) + component <- validate_argument(component, c("all", "conditional", "nonlinear")) startvectors <- .get_startvector_from_env(x) fx <- lme4::fixef(x) @@ -183,13 +269,11 @@ get_parameters.nlmerMod <- function(x, } - -#' @rdname get_parameters.glmm #' @export -get_parameters.merMod <- function(x, effects = c("fixed", "random"), ...) { +get_parameters.merMod <- function(x, effects = "fixed", ...) { check_if_installed("lme4") - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { l <- list(conditional = lme4::fixef(x)) @@ -217,7 +301,7 @@ get_parameters.merMod <- function(x, effects = c("fixed", "random"), ...) { get_parameters.rlmerMod <- get_parameters.merMod #' @export -get_parameters.glmmadmb <- get_parameters.merMod +get_parameters.glmmTMBadmb <- get_parameters.merMod #' @export get_parameters.lme <- get_parameters.merMod @@ -247,11 +331,12 @@ get_parameters.merModList <- function(x, ...) { text_remove_backticks(fixed) } + #' @export -get_parameters.HLfit <- function(x, effects = c("fixed", "random"), ...) { +get_parameters.HLfit <- function(x, effects = "fixed", ...) { check_if_installed("lme4") - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { l <- list(conditional = lme4::fixef(x)) @@ -277,14 +362,13 @@ get_parameters.HLfit <- function(x, effects = c("fixed", "random"), ...) { } - #' @export -get_parameters.sem <- function(x, effects = c("fixed", "random"), ...) { +get_parameters.sem <- function(x, effects = "fixed", ...) { if (!.is_semLme(x)) { return(NULL) } - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { l <- list(conditional = x$coef) @@ -309,12 +393,11 @@ get_parameters.sem <- function(x, effects = c("fixed", "random"), ...) { } - #' @export -get_parameters.cpglmm <- function(x, effects = c("fixed", "random"), ...) { +get_parameters.cpglmm <- function(x, effects = "fixed", ...) { check_if_installed("cplm") - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { l <- list(conditional = cplm::fixef(x)) @@ -339,12 +422,11 @@ get_parameters.cpglmm <- function(x, effects = c("fixed", "random"), ...) { } - #' @export -get_parameters.mixed <- function(x, effects = c("fixed", "random"), ...) { +get_parameters.mixed <- function(x, effects = "fixed", ...) { check_if_installed("lme4") - effects <- match.arg(effects) + effects <- validate_argument(effects, c("fixed", "random")) if (effects == "fixed") { l <- list(conditional = lme4::fixef(x$full_model)) @@ -369,15 +451,15 @@ get_parameters.mixed <- function(x, effects = c("fixed", "random"), ...) { } - #' @export -get_parameters.MixMod <- function(x, - effects = c("fixed", "random"), - component = c("all", "conditional", "zi", "zero_inflated", "dispersion"), ...) { +get_parameters.MixMod <- function(x, effects = "fixed", component = "all", ...) { check_if_installed("lme4") - effects <- match.arg(effects) - component <- match.arg(component) + effects <- validate_argument(effects, c("fixed", "random")) + component <- validate_argument( + component, + c("all", "conditional", "zi", "zero_inflated", "dispersion", "location", "distributional", "auxiliary") # nolint + ) has_zeroinf <- !is.null(find_formula(x, verbose = FALSE)[["zero_inflated"]]) @@ -385,11 +467,9 @@ get_parameters.MixMod <- function(x, format_error("Model has no zero-inflation component.") } - re.names <- dimnames(lme4::ranef(x))[[2]] re <- lme4::ranef(x) - if (has_zeroinf) { z_inflated <- lme4::fixef(x, sub_model = "zero_part") z_inflated_random <- re[startsWith(re.names, "zi_")] @@ -444,105 +524,14 @@ get_parameters.MixMod <- function(x, } - -#' @rdname get_parameters.glmm #' @export -get_parameters.glmmTMB <- function(x, - effects = c("fixed", "random"), - component = c("all", "conditional", "zi", "zero_inflated", "dispersion"), ...) { - check_if_installed("lme4") - - effects <- match.arg(effects) - component <- match.arg(component) - - if (effects == "fixed") { - l <- compact_list(list( - conditional = lme4::fixef(x)$cond, - zero_inflated = lme4::fixef(x)$zi, - dispersion = lme4::fixef(x)$disp - )) - } else { - l <- compact_list(list( - conditional = lme4::fixef(x)$cond, - random = lme4::ranef(x)$cond, - zero_inflated = lme4::fixef(x)$zi, - zero_inflated_random = lme4::ranef(x)$zi, - dispersion = lme4::fixef(x)$disp, - dispersion_random = lme4::ranef(x)$disp - )) - } - - # ---- fixed effects (conditional model) - - fixed <- data.frame( - Parameter = names(l$conditional), - Estimate = unname(l$conditional), - Component = "conditional", - stringsAsFactors = FALSE +get_parameters.hglm <- function(x, effects = "fixed", component = "all", ...) { + effects <- validate_argument(effects, c("fixed", "random")) + component <- validate_argument( + component, + c("all", "conditional", "dispersion", "location", "distributional", "auxiliary") ) - # ---- fixed effects (zero_inflated model) - - if (object_has_names(l, "zero_inflated")) { - fixedzi <- data.frame( - Parameter = names(l$zero_inflated), - Estimate = unname(l$zero_inflated), - Component = "zero_inflated", - stringsAsFactors = FALSE - ) - } else { - fixedzi <- NULL - } - - # ---- fixed effects (dispersion model) - - if (object_has_names(l, "dispersion")) { - fixeddisp <- data.frame( - Parameter = names(l$dispersion), - Estimate = unname(l$dispersion), - Component = "dispersion", - stringsAsFactors = FALSE - ) - } else { - fixeddisp <- NULL - } - - # ---- build result - - if (effects == "fixed") { - out <- switch(component, - all = rbind(fixed, fixedzi, fixeddisp), - conditional = fixed, - zi = , - zero_inflated = fixedzi, - dispersion = fixeddisp - ) - text_remove_backticks(out) - } else if (effects == "random") { - switch(component, - all = compact_list(list( - random = l$random, - zero_inflated_random = l$zero_inflated_random, - dispersion_random = l$dispersion_random - )), - conditional = l$random, - zi = , - zero_inflated = l$zero_inflated_random, - dispersion_random = l$dispersion_random - ) - } -} - - - -#' @export -get_parameters.hglm <- function(x, - effects = c("fixed", "random", "all"), - component = c("all", "conditional", "dispersion"), - ...) { - effects <- match.arg(effects) - component <- match.arg(component) - fe <- x$fixef re <- x$ranef @@ -590,11 +579,10 @@ get_parameters.hglm <- function(x, } - #' @export -get_parameters.mixor <- function(x, effects = c("all", "fixed", "random"), ...) { +get_parameters.mixor <- function(x, effects = "all", ...) { coefs <- stats::coef(x) - effects <- match.arg(effects) + effects <- validate_argument(effects, c("all", "fixed", "random")) params <- find_parameters(x, effects = "fixed", flatten = TRUE) fixed <- data.frame( @@ -624,10 +612,9 @@ get_parameters.mixor <- function(x, effects = c("all", "fixed", "random"), ...) } - #' @export -get_parameters.BBmm <- function(x, effects = c("fixed", "random"), ...) { - effects <- match.arg(effects) +get_parameters.BBmm <- function(x, effects = "fixed", ...) { + effects <- validate_argument(effects, c("fixed", "random")) l <- compact_list(list( conditional = x$fixed.coef, @@ -649,11 +636,9 @@ get_parameters.BBmm <- function(x, effects = c("fixed", "random"), ...) { } - -#' @rdname get_parameters.glmm #' @export -get_parameters.glimML <- function(x, effects = c("fixed", "random", "all"), ...) { - effects <- match.arg(effects) +get_parameters.glimML <- function(x, effects = "fixed", ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) l <- compact_list(list( conditional = x@fixed.param, diff --git a/R/get_parameters_zi.R b/R/get_parameters_zi.R index 8e512ba92..1551253d2 100644 --- a/R/get_parameters_zi.R +++ b/R/get_parameters_zi.R @@ -19,10 +19,8 @@ #' m <- lm(mpg ~ wt + cyl + vs, data = mtcars) #' get_parameters(m) #' @export -get_parameters.zeroinfl <- function(x, - component = c("all", "conditional", "zi", "zero_inflated"), - ...) { - component <- match.arg(component) +get_parameters.zeroinfl <- function(x, component = "all", ...) { + component <- validate_argument(component, c("all", "conditional", "zi", "zero_inflated")) .return_zeroinf_parms(x, component) } @@ -33,12 +31,9 @@ get_parameters.hurdle <- get_parameters.zeroinfl get_parameters.zerotrunc <- get_parameters.default -#' @rdname get_parameters.zeroinfl #' @export -get_parameters.zcpglm <- function(x, - component = c("all", "conditional", "zi", "zero_inflated"), - ...) { - component <- match.arg(component) +get_parameters.zcpglm <- function(x, component = "all", ...) { + component <- validate_argument(component, c("all", "conditional", "zi", "zero_inflated")) cf <- stats::coef(x) cond <- data.frame( @@ -114,14 +109,15 @@ get_parameters.zcpglm <- function(x, } - - -#' @rdname get_parameters.zeroinfl #' @export -get_parameters.mhurdle <- function(x, - component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", "auxiliary"), - ...) { - component <- match.arg(component) +get_parameters.mhurdle <- function(x, component = "all", ...) { + component <- validate_argument( + component, + c( + "all", "conditional", "zi", "zero_inflated", + "infrequent_purchase", "ip", "auxiliary" + ) + ) cf <- stats::coef(x) cond_pars <- which(startsWith(names(cf), "h2.")) diff --git a/R/n_parameters.R b/R/n_parameters.R index 120258295..d283c2c26 100644 --- a/R/n_parameters.R +++ b/R/n_parameters.R @@ -3,8 +3,6 @@ #' Returns the number of parameters (coefficients) of a model. #' #' @param x A statistical model. -#' @param effects Should number of parameters for fixed effects, random effects -#' or both be returned? Only applies to mixed models. May be abbreviated. #' @param component Should total number of parameters, number parameters for the #' conditional model, the zero-inflated part of the model, the dispersion term #' or the instrumental variables be returned? Applies to models with @@ -14,6 +12,7 @@ #' count) non-estimable parameters (which may occur for models with #' rank-deficient model matrix). #' @param ... Arguments passed to or from other methods. +#' @inheritParams find_predictors #' #' @return The number of parameters in the model. #' diff --git a/inst/WORDLIST b/inst/WORDLIST index cb304140c..000f62cb0 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -101,6 +101,7 @@ glm glmm glmmTMB glmtoolbox +glmx hglm htest https @@ -131,6 +132,7 @@ mfx mgcv mhurdle mira +mjoint mmrm modelled modelling diff --git a/man/find_parameters.BGGM.Rd b/man/find_parameters.BGGM.Rd index 7192c8db5..ffa2f6842 100644 --- a/man/find_parameters.BGGM.Rd +++ b/man/find_parameters.BGGM.Rd @@ -19,29 +19,34 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Which type of parameters to return, such as parameters for the -conditional model, the zero-inflated part of the model, the dispersion -term, the instrumental variables or marginal effects be returned? Applies -to models with zero-inflated and/or dispersion formula, or to models with -instrumental variables (so called fixed-effects regressions), or models -with marginal effects from \strong{mfx}. May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model. There are three convenient shortcuts: -\code{component = "all"} returns all possible parameters. -If \code{component = "location"}, location parameters such as \code{conditional}, -\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned -(everything that are fixed or random effects - depending on the \code{effects} -argument - but no auxiliary parameters). For \code{component = "distributional"} -(or \code{"auxiliary"}), components like \code{sigma}, \code{dispersion}, -\code{beta} or \code{precision} (and other auxiliary parameters) are returned.} +\item{component}{Which type of parameters to return, such as parameters for +the conditional model, the zero-inflated part of the model, the dispersion +term, the instrumental variables or marginal effects be returned? Applies to +models with zero-inflated and/or dispersion formula, or to models with +instrumental variables (so called fixed-effects regressions), or models with +marginal effects from \strong{mfx}. See details in section \emph{Model Components} .May +be abbreviated. Note that the \emph{conditional} component also refers to the +\emph{count} or \emph{mean} component - names may differ, depending on the modeling +package. There are three convenient shortcuts: +\itemize{ +\item \code{component = "all"} returns all possible parameters. +\item If \code{component = "location"}, location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned (everything +that are fixed or random effects - depending on the \code{effects} argument - +but no auxiliary parameters). +\item For \code{component = "distributional"} (or \code{"auxiliary"}), components like +\code{sigma}, \code{dispersion}, \code{beta} or \code{precision} (and other auxiliary +parameters) are returned. +}} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} \item{...}{Currently not used.} -\item{effects}{Should parameters for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{parameters}{Regular expression pattern that describes the parameters that should be returned.} diff --git a/man/find_parameters.Rd b/man/find_parameters.Rd index ed3eafd8e..7494b3e63 100644 --- a/man/find_parameters.Rd +++ b/man/find_parameters.Rd @@ -71,12 +71,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \section{Parameters, Variables, Predictors and Terms}{ diff --git a/man/find_parameters.averaging.Rd b/man/find_parameters.averaging.Rd index d36a94404..43f1031c5 100644 --- a/man/find_parameters.averaging.Rd +++ b/man/find_parameters.averaging.Rd @@ -9,21 +9,25 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Which type of parameters to return, such as parameters for the -conditional model, the zero-inflated part of the model, the dispersion -term, the instrumental variables or marginal effects be returned? Applies -to models with zero-inflated and/or dispersion formula, or to models with -instrumental variables (so called fixed-effects regressions), or models -with marginal effects from \strong{mfx}. May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model. There are three convenient shortcuts: -\code{component = "all"} returns all possible parameters. -If \code{component = "location"}, location parameters such as \code{conditional}, -\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned -(everything that are fixed or random effects - depending on the \code{effects} -argument - but no auxiliary parameters). For \code{component = "distributional"} -(or \code{"auxiliary"}), components like \code{sigma}, \code{dispersion}, -\code{beta} or \code{precision} (and other auxiliary parameters) are returned.} +\item{component}{Which type of parameters to return, such as parameters for +the conditional model, the zero-inflated part of the model, the dispersion +term, the instrumental variables or marginal effects be returned? Applies to +models with zero-inflated and/or dispersion formula, or to models with +instrumental variables (so called fixed-effects regressions), or models with +marginal effects from \strong{mfx}. See details in section \emph{Model Components} .May +be abbreviated. Note that the \emph{conditional} component also refers to the +\emph{count} or \emph{mean} component - names may differ, depending on the modeling +package. There are three convenient shortcuts: +\itemize{ +\item \code{component = "all"} returns all possible parameters. +\item If \code{component = "location"}, location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned (everything +that are fixed or random effects - depending on the \code{effects} argument - +but no auxiliary parameters). +\item For \code{component = "distributional"} (or \code{"auxiliary"}), components like +\code{sigma}, \code{dispersion}, \code{beta} or \code{precision} (and other auxiliary +parameters) are returned. +}} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} diff --git a/man/find_parameters.betamfx.Rd b/man/find_parameters.betamfx.Rd index 714c472df..2f2a82823 100644 --- a/man/find_parameters.betamfx.Rd +++ b/man/find_parameters.betamfx.Rd @@ -12,21 +12,25 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Which type of parameters to return, such as parameters for the -conditional model, the zero-inflated part of the model, the dispersion -term, the instrumental variables or marginal effects be returned? Applies -to models with zero-inflated and/or dispersion formula, or to models with -instrumental variables (so called fixed-effects regressions), or models -with marginal effects from \strong{mfx}. May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model. There are three convenient shortcuts: -\code{component = "all"} returns all possible parameters. -If \code{component = "location"}, location parameters such as \code{conditional}, -\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned -(everything that are fixed or random effects - depending on the \code{effects} -argument - but no auxiliary parameters). For \code{component = "distributional"} -(or \code{"auxiliary"}), components like \code{sigma}, \code{dispersion}, -\code{beta} or \code{precision} (and other auxiliary parameters) are returned.} +\item{component}{Which type of parameters to return, such as parameters for +the conditional model, the zero-inflated part of the model, the dispersion +term, the instrumental variables or marginal effects be returned? Applies to +models with zero-inflated and/or dispersion formula, or to models with +instrumental variables (so called fixed-effects regressions), or models with +marginal effects from \strong{mfx}. See details in section \emph{Model Components} .May +be abbreviated. Note that the \emph{conditional} component also refers to the +\emph{count} or \emph{mean} component - names may differ, depending on the modeling +package. There are three convenient shortcuts: +\itemize{ +\item \code{component = "all"} returns all possible parameters. +\item If \code{component = "location"}, location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned (everything +that are fixed or random effects - depending on the \code{effects} argument - +but no auxiliary parameters). +\item For \code{component = "distributional"} (or \code{"auxiliary"}), components like +\code{sigma}, \code{dispersion}, \code{beta} or \code{precision} (and other auxiliary +parameters) are returned. +}} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} @@ -46,6 +50,52 @@ elements: Returns the names of model parameters, like they typically appear in the \code{summary()} output. } +\section{Model components}{ + +Possible values for the \code{component} argument depend on the model class. +Following are valid options: +\itemize{ +\item \code{"all"}: returns all model components, applies to all models, but will only +have an effect for models with more than just the conditional model component. +\item \code{"conditional"}: only returns the conditional component, i.e. "fixed effects" +terms from the model. Will only have an effect for models with more than +just the conditional model component. +\item \code{"smooth_terms"}: returns smooth terms, only applies to GAMs (or similar +models that may contain smooth terms). +\item \code{"zero_inflated"} (or \code{"zi"}): returns the zero-inflation component. +\item \code{"dispersion"}: returns the dispersion model component. This is common +for models with zero-inflation or that can model the dispersion parameter. +\item \code{"instruments"}: for instrumental-variable or some fixed effects regression, +returns the instruments. +\item \code{"nonlinear"}: for non-linear models (like models of class \code{nlmerMod} or +\code{nls}), returns staring estimates for the nonlinear parameters. +\item \code{"correlation"}: for models with correlation-component, like \code{gls}, the +variables used to describe the correlation structure are returned. +\item \code{"location"}: returns location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} (everything that are +fixed or random effects - depending on the \code{effects} argument - but no +auxiliary parameters). +\item \code{"distributional"} (or \code{"auxiliary"}): components like \code{sigma}, \code{dispersion}, +\code{beta} or \code{precision} (and other auxiliary parameters) are returned. +} + +\strong{Special models} + +Some model classes also allow rather uncommon options. These are: +\itemize{ +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} +} + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. +} + \examples{ data(mtcars) m <- lm(mpg ~ wt + cyl + vs, data = mtcars) diff --git a/man/find_parameters.gamlss.Rd b/man/find_parameters.gamlss.Rd index 091b5dc43..f42e5bcb9 100644 --- a/man/find_parameters.gamlss.Rd +++ b/man/find_parameters.gamlss.Rd @@ -17,21 +17,25 @@ vector, not as list. Duplicated values are removed.} \item{...}{Currently not used.} -\item{component}{Which type of parameters to return, such as parameters for the -conditional model, the zero-inflated part of the model, the dispersion -term, the instrumental variables or marginal effects be returned? Applies -to models with zero-inflated and/or dispersion formula, or to models with -instrumental variables (so called fixed-effects regressions), or models -with marginal effects from \strong{mfx}. May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model. There are three convenient shortcuts: -\code{component = "all"} returns all possible parameters. -If \code{component = "location"}, location parameters such as \code{conditional}, -\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned -(everything that are fixed or random effects - depending on the \code{effects} -argument - but no auxiliary parameters). For \code{component = "distributional"} -(or \code{"auxiliary"}), components like \code{sigma}, \code{dispersion}, -\code{beta} or \code{precision} (and other auxiliary parameters) are returned.} +\item{component}{Which type of parameters to return, such as parameters for +the conditional model, the zero-inflated part of the model, the dispersion +term, the instrumental variables or marginal effects be returned? Applies to +models with zero-inflated and/or dispersion formula, or to models with +instrumental variables (so called fixed-effects regressions), or models with +marginal effects from \strong{mfx}. See details in section \emph{Model Components} .May +be abbreviated. Note that the \emph{conditional} component also refers to the +\emph{count} or \emph{mean} component - names may differ, depending on the modeling +package. There are three convenient shortcuts: +\itemize{ +\item \code{component = "all"} returns all possible parameters. +\item If \code{component = "location"}, location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned (everything +that are fixed or random effects - depending on the \code{effects} argument - +but no auxiliary parameters). +\item For \code{component = "distributional"} (or \code{"auxiliary"}), components like +\code{sigma}, \code{dispersion}, \code{beta} or \code{precision} (and other auxiliary +parameters) are returned. +}} } \value{ A list of parameter names. The returned list may have following diff --git a/man/find_parameters.glmmTMB.Rd b/man/find_parameters.glmmTMB.Rd index a078e13e8..f880da002 100644 --- a/man/find_parameters.glmmTMB.Rd +++ b/man/find_parameters.glmmTMB.Rd @@ -9,8 +9,9 @@ \arguments{ \item{x}{A fitted model.} -\item{effects}{Should parameters for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{component}{Which type of parameters to return, such as parameters for the conditional model, the zero-inflated part of the model or the @@ -23,7 +24,8 @@ parameters. If \code{component = "location"}, location parameters such as are fixed or random effects - depending on the \code{effects} argument - but no auxiliary parameters). For \code{component = "distributional"} (or \code{"auxiliary"}), components like \code{sigma} or \code{dispersion} (and -other auxiliary parameters) are returned.} +other auxiliary parameters) are returned. See section \emph{Model Component} +for details.} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} @@ -51,6 +53,52 @@ parameters (auxiliary parameter) Returns the names of model parameters, like they typically appear in the \code{summary()} output. } +\section{Model components}{ + +Possible values for the \code{component} argument depend on the model class. +Following are valid options: +\itemize{ +\item \code{"all"}: returns all model components, applies to all models, but will only +have an effect for models with more than just the conditional model component. +\item \code{"conditional"}: only returns the conditional component, i.e. "fixed effects" +terms from the model. Will only have an effect for models with more than +just the conditional model component. +\item \code{"smooth_terms"}: returns smooth terms, only applies to GAMs (or similar +models that may contain smooth terms). +\item \code{"zero_inflated"} (or \code{"zi"}): returns the zero-inflation component. +\item \code{"dispersion"}: returns the dispersion model component. This is common +for models with zero-inflation or that can model the dispersion parameter. +\item \code{"instruments"}: for instrumental-variable or some fixed effects regression, +returns the instruments. +\item \code{"nonlinear"}: for non-linear models (like models of class \code{nlmerMod} or +\code{nls}), returns staring estimates for the nonlinear parameters. +\item \code{"correlation"}: for models with correlation-component, like \code{gls}, the +variables used to describe the correlation structure are returned. +\item \code{"location"}: returns location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} (everything that are +fixed or random effects - depending on the \code{effects} argument - but no +auxiliary parameters). +\item \code{"distributional"} (or \code{"auxiliary"}): components like \code{sigma}, \code{dispersion}, +\code{beta} or \code{precision} (and other auxiliary parameters) are returned. +} + +\strong{Special models} + +Some model classes also allow rather uncommon options. These are: +\itemize{ +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} +} + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. +} + \examples{ \dontshow{if (requireNamespace("lme4", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(sleepstudy, package = "lme4") diff --git a/man/find_parameters.zeroinfl.Rd b/man/find_parameters.zeroinfl.Rd index 3b2714e01..37520a191 100644 --- a/man/find_parameters.zeroinfl.Rd +++ b/man/find_parameters.zeroinfl.Rd @@ -9,21 +9,25 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Which type of parameters to return, such as parameters for the -conditional model, the zero-inflated part of the model, the dispersion -term, the instrumental variables or marginal effects be returned? Applies -to models with zero-inflated and/or dispersion formula, or to models with -instrumental variables (so called fixed-effects regressions), or models -with marginal effects from \strong{mfx}. May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model. There are three convenient shortcuts: -\code{component = "all"} returns all possible parameters. -If \code{component = "location"}, location parameters such as \code{conditional}, -\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned -(everything that are fixed or random effects - depending on the \code{effects} -argument - but no auxiliary parameters). For \code{component = "distributional"} -(or \code{"auxiliary"}), components like \code{sigma}, \code{dispersion}, -\code{beta} or \code{precision} (and other auxiliary parameters) are returned.} +\item{component}{Which type of parameters to return, such as parameters for +the conditional model, the zero-inflated part of the model, the dispersion +term, the instrumental variables or marginal effects be returned? Applies to +models with zero-inflated and/or dispersion formula, or to models with +instrumental variables (so called fixed-effects regressions), or models with +marginal effects from \strong{mfx}. See details in section \emph{Model Components} .May +be abbreviated. Note that the \emph{conditional} component also refers to the +\emph{count} or \emph{mean} component - names may differ, depending on the modeling +package. There are three convenient shortcuts: +\itemize{ +\item \code{component = "all"} returns all possible parameters. +\item If \code{component = "location"}, location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned (everything +that are fixed or random effects - depending on the \code{effects} argument - +but no auxiliary parameters). +\item For \code{component = "distributional"} (or \code{"auxiliary"}), components like +\code{sigma}, \code{dispersion}, \code{beta} or \code{precision} (and other auxiliary +parameters) are returned. +}} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} @@ -45,6 +49,52 @@ component of the model. Returns the names of model parameters, like they typically appear in the \code{summary()} output. } +\section{Model components}{ + +Possible values for the \code{component} argument depend on the model class. +Following are valid options: +\itemize{ +\item \code{"all"}: returns all model components, applies to all models, but will only +have an effect for models with more than just the conditional model component. +\item \code{"conditional"}: only returns the conditional component, i.e. "fixed effects" +terms from the model. Will only have an effect for models with more than +just the conditional model component. +\item \code{"smooth_terms"}: returns smooth terms, only applies to GAMs (or similar +models that may contain smooth terms). +\item \code{"zero_inflated"} (or \code{"zi"}): returns the zero-inflation component. +\item \code{"dispersion"}: returns the dispersion model component. This is common +for models with zero-inflation or that can model the dispersion parameter. +\item \code{"instruments"}: for instrumental-variable or some fixed effects regression, +returns the instruments. +\item \code{"nonlinear"}: for non-linear models (like models of class \code{nlmerMod} or +\code{nls}), returns staring estimates for the nonlinear parameters. +\item \code{"correlation"}: for models with correlation-component, like \code{gls}, the +variables used to describe the correlation structure are returned. +\item \code{"location"}: returns location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} (everything that are +fixed or random effects - depending on the \code{effects} argument - but no +auxiliary parameters). +\item \code{"distributional"} (or \code{"auxiliary"}): components like \code{sigma}, \code{dispersion}, +\code{beta} or \code{precision} (and other auxiliary parameters) are returned. +} + +\strong{Special models} + +Some model classes also allow rather uncommon options. These are: +\itemize{ +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} +} + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. +} + \examples{ \dontshow{if (requireNamespace("pscl", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(bioChemists, package = "pscl") diff --git a/man/find_predictors.Rd b/man/find_predictors.Rd index 9f1fae4b2..d5a74fb2e 100644 --- a/man/find_predictors.Rd +++ b/man/find_predictors.Rd @@ -21,8 +21,9 @@ find_predictors(x, ...) \item{...}{Currently not used.} -\item{effects}{Should variables for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{component}{Indicates which model component should be returned. E.g., should all predictor variables, predictor variables for the conditional @@ -97,12 +98,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \section{Parameters, Variables, Predictors and Terms}{ diff --git a/man/find_variables.Rd b/man/find_variables.Rd index 28b0c0501..0101bd37b 100644 --- a/man/find_variables.Rd +++ b/man/find_variables.Rd @@ -15,8 +15,9 @@ find_variables( \arguments{ \item{x}{A fitted model.} -\item{effects}{Should variables for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{component}{Indicates which model component should be returned. E.g., should all predictor variables, predictor variables for the conditional @@ -89,12 +90,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \section{Parameters, Variables, Predictors and Terms}{ diff --git a/man/get_data.Rd b/man/get_data.Rd index a25497f55..98c7005f7 100644 --- a/man/get_data.Rd +++ b/man/get_data.Rd @@ -124,12 +124,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/get_parameters.BGGM.Rd b/man/get_parameters.BGGM.Rd index 3d98ff732..21fc660c7 100644 --- a/man/get_parameters.BGGM.Rd +++ b/man/get_parameters.BGGM.Rd @@ -2,28 +2,13 @@ % Please edit documentation in R/get_parameters_bayesian.R \name{get_parameters.BGGM} \alias{get_parameters.BGGM} -\alias{get_parameters.MCMCglmm} \alias{get_parameters.BFBayesFactor} -\alias{get_parameters.stanmvreg} \alias{get_parameters.brmsfit} -\alias{get_parameters.stanreg} -\alias{get_parameters.bayesx} -\alias{get_parameters.bamlss} -\alias{get_parameters.sim.merMod} -\alias{get_parameters.sim} \title{Get model parameters from Bayesian models} \usage{ \method{get_parameters}{BGGM}( x, - component = c("correlation", "conditional", "intercept", "all"), - summary = FALSE, - centrality = "mean", - ... -) - -\method{get_parameters}{MCMCglmm}( - x, - effects = c("fixed", "random", "all"), + component = "correlation", summary = FALSE, centrality = "mean", ... @@ -31,8 +16,8 @@ \method{get_parameters}{BFBayesFactor}( x, - effects = c("all", "fixed", "random"), - component = c("all", "extra"), + effects = "all", + component = "all", iterations = 4000, progress = FALSE, verbose = TRUE, @@ -41,15 +26,6 @@ ... ) -\method{get_parameters}{stanmvreg}( - x, - effects = c("fixed", "random", "all"), - parameters = NULL, - summary = FALSE, - centrality = "mean", - ... -) - \method{get_parameters}{brmsfit}( x, effects = "fixed", @@ -59,65 +35,29 @@ centrality = "mean", ... ) - -\method{get_parameters}{stanreg}( - x, - effects = c("fixed", "random", "all"), - component = c("location", "all", "conditional", "smooth_terms", "sigma", - "distributional", "auxiliary"), - parameters = NULL, - summary = FALSE, - centrality = "mean", - ... -) - -\method{get_parameters}{bayesx}( - x, - component = c("conditional", "smooth_terms", "all"), - summary = FALSE, - centrality = "mean", - ... -) - -\method{get_parameters}{bamlss}( - x, - component = c("all", "conditional", "smooth_terms", "location", "distributional", - "auxiliary"), - parameters = NULL, - summary = FALSE, - centrality = "mean", - ... -) - -\method{get_parameters}{sim.merMod}( - x, - effects = c("fixed", "random", "all"), - parameters = NULL, - summary = FALSE, - centrality = "mean", - ... -) - -\method{get_parameters}{sim}(x, parameters = NULL, summary = FALSE, centrality = "mean", ...) } \arguments{ \item{x}{A fitted model.} -\item{component}{Which type of parameters to return, such as parameters for the -conditional model, the zero-inflated part of the model, the dispersion -term, the instrumental variables or marginal effects be returned? Applies -to models with zero-inflated and/or dispersion formula, or to models with -instrumental variables (so called fixed-effects regressions), or models -with marginal effects from \strong{mfx}. May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model. There are three convenient shortcuts: -\code{component = "all"} returns all possible parameters. -If \code{component = "location"}, location parameters such as \code{conditional}, -\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned -(everything that are fixed or random effects - depending on the \code{effects} -argument - but no auxiliary parameters). For \code{component = "distributional"} -(or \code{"auxiliary"}), components like \code{sigma}, \code{dispersion}, -\code{beta} or \code{precision} (and other auxiliary parameters) are returned.} +\item{component}{Which type of parameters to return, such as parameters for +the conditional model, the zero-inflated part of the model, the dispersion +term, the instrumental variables or marginal effects be returned? Applies to +models with zero-inflated and/or dispersion formula, or to models with +instrumental variables (so called fixed-effects regressions), or models with +marginal effects from \strong{mfx}. See details in section \emph{Model Components} .May +be abbreviated. Note that the \emph{conditional} component also refers to the +\emph{count} or \emph{mean} component - names may differ, depending on the modeling +package. There are three convenient shortcuts: +\itemize{ +\item \code{component = "all"} returns all possible parameters. +\item If \code{component = "location"}, location parameters such as \code{conditional}, +\code{zero_inflated}, \code{smooth_terms}, or \code{instruments} are returned (everything +that are fixed or random effects - depending on the \code{effects} argument - +but no auxiliary parameters). +\item For \code{component = "distributional"} (or \code{"auxiliary"}), components like +\code{sigma}, \code{dispersion}, \code{beta} or \code{precision} (and other auxiliary +parameters) are returned. +}} \item{summary}{Logical, indicates whether the full posterior samples (\code{summary = FALSE})) or the summarized centrality indices of @@ -132,8 +72,9 @@ measure of central tendency.} \item{...}{Currently not used.} -\item{effects}{Should parameters for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{iterations}{Number of posterior draws.} @@ -201,12 +142,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/get_parameters.Rd b/man/get_parameters.Rd index ad3cb08dd..77699854e 100644 --- a/man/get_parameters.Rd +++ b/man/get_parameters.Rd @@ -32,7 +32,7 @@ models) from a model. See the documentation for your object's class: \item \link[=get_parameters.emmGrid]{Estimated marginal means} (\strong{emmeans}) \item \link[=get_parameters.gamm]{Generalized additive models} (\strong{mgcv}, \strong{VGAM}, ...) \item \link[=get_parameters.betamfx]{Marginal effects models} (\strong{mfx}) -\item \link[=get_parameters.glmm]{Mixed models} (\strong{lme4}, \strong{glmmTMB}, \strong{GLMMadaptive}, ...) +\item \link[=get_parameters.glmmTMB]{Mixed models} (\strong{lme4}, \strong{glmmTMB}, \strong{GLMMadaptive}, ...) \item \link[=get_parameters.zeroinfl]{Zero-inflated and hurdle models} (\strong{pscl}, ...) \item \link[=get_parameters.betareg]{Models with special components} (\strong{betareg}, \strong{MuMIn}, ...) \item \link[=get_parameters.htest]{Hypothesis tests} (\code{htest}) @@ -81,12 +81,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/get_parameters.betamfx.Rd b/man/get_parameters.betamfx.Rd index 663c659c1..b14fb5acd 100644 --- a/man/get_parameters.betamfx.Rd +++ b/man/get_parameters.betamfx.Rd @@ -65,12 +65,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/get_parameters.betareg.Rd b/man/get_parameters.betareg.Rd index 5de88303a..4a5bbd594 100644 --- a/man/get_parameters.betareg.Rd +++ b/man/get_parameters.betareg.Rd @@ -97,12 +97,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/get_parameters.emmGrid.Rd b/man/get_parameters.emmGrid.Rd index 778f78bfe..eefb35301 100644 --- a/man/get_parameters.emmGrid.Rd +++ b/man/get_parameters.emmGrid.Rd @@ -2,12 +2,9 @@ % Please edit documentation in R/get_parameters_emmeans.R \name{get_parameters.emmGrid} \alias{get_parameters.emmGrid} -\alias{get_parameters.emm_list} \title{Get model parameters from estimated marginal means objects} \usage{ \method{get_parameters}{emmGrid}(x, summary = FALSE, merge_parameters = FALSE, ...) - -\method{get_parameters}{emm_list}(x, summary = FALSE, ...) } \arguments{ \item{x}{A fitted model.} diff --git a/man/get_parameters.gamm.Rd b/man/get_parameters.gamm.Rd index 88101b772..7e6cecc67 100644 --- a/man/get_parameters.gamm.Rd +++ b/man/get_parameters.gamm.Rd @@ -73,12 +73,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/get_parameters.glmm.Rd b/man/get_parameters.glmmTMB.Rd similarity index 71% rename from man/get_parameters.glmm.Rd rename to man/get_parameters.glmmTMB.Rd index 803214690..d4c60234c 100644 --- a/man/get_parameters.glmm.Rd +++ b/man/get_parameters.glmmTMB.Rd @@ -1,43 +1,17 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_parameters_mixed.R -\name{get_parameters.glmm} -\alias{get_parameters.glmm} -\alias{get_parameters.coxme} -\alias{get_parameters.nlmerMod} -\alias{get_parameters.merMod} +\name{get_parameters.glmmTMB} \alias{get_parameters.glmmTMB} -\alias{get_parameters.glimML} \title{Get model parameters from mixed models} \usage{ -\method{get_parameters}{glmm}(x, effects = c("all", "fixed", "random"), ...) - -\method{get_parameters}{coxme}(x, effects = c("fixed", "random"), ...) - -\method{get_parameters}{nlmerMod}( - x, - effects = c("fixed", "random"), - component = c("all", "conditional", "nonlinear"), - ... -) - -\method{get_parameters}{merMod}(x, effects = c("fixed", "random"), ...) - -\method{get_parameters}{glmmTMB}( - x, - effects = c("fixed", "random"), - component = c("all", "conditional", "zi", "zero_inflated", "dispersion"), - ... -) - -\method{get_parameters}{glimML}(x, effects = c("fixed", "random", "all"), ...) +\method{get_parameters}{glmmTMB}(x, effects = "fixed", component = "all", ...) } \arguments{ \item{x}{A fitted model.} -\item{effects}{Should parameters for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} - -\item{...}{Currently not used.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{component}{Which type of parameters to return, such as parameters for the conditional model, the zero-inflated part of the model or the @@ -50,7 +24,10 @@ parameters. If \code{component = "location"}, location parameters such as are fixed or random effects - depending on the \code{effects} argument - but no auxiliary parameters). For \code{component = "distributional"} (or \code{"auxiliary"}), components like \code{sigma} or \code{dispersion} (and -other auxiliary parameters) are returned.} +other auxiliary parameters) are returned. See section \emph{Model Component} +for details.} + +\item{...}{Currently not used.} } \value{ If \code{effects = "fixed"}, a data frame with two columns: the @@ -64,7 +41,8 @@ Returns the coefficients from a model. \details{ In most cases when models either return different "effects" (fixed, random) or "components" (conditional, zero-inflated, ...), the arguments -\code{effects} and \code{component} can be used. +\code{effects} and \code{component} can be used. See details in the section +\emph{Model Components}. } \section{Model components}{ @@ -99,16 +77,28 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ -data(mtcars) -m <- lm(mpg ~ wt + cyl + vs, data = mtcars) +\dontshow{if (requireNamespace("glmmTMB", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(Salamanders, package = "glmmTMB") +m <- glmmTMB::glmmTMB( + count ~ mined + (1 | site), + ziformula = ~mined, + family = poisson(), + data = Salamanders +) get_parameters(m) +\dontshow{\}) # examplesIf} } diff --git a/man/get_parameters.zeroinfl.Rd b/man/get_parameters.zeroinfl.Rd index ec91de4fd..709f59dcb 100644 --- a/man/get_parameters.zeroinfl.Rd +++ b/man/get_parameters.zeroinfl.Rd @@ -2,28 +2,9 @@ % Please edit documentation in R/get_parameters_zi.R \name{get_parameters.zeroinfl} \alias{get_parameters.zeroinfl} -\alias{get_parameters.zcpglm} -\alias{get_parameters.mhurdle} \title{Get model parameters from zero-inflated and hurdle models} \usage{ -\method{get_parameters}{zeroinfl}( - x, - component = c("all", "conditional", "zi", "zero_inflated"), - ... -) - -\method{get_parameters}{zcpglm}( - x, - component = c("all", "conditional", "zi", "zero_inflated"), - ... -) - -\method{get_parameters}{mhurdle}( - x, - component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", - "auxiliary"), - ... -) +\method{get_parameters}{zeroinfl}(x, component = "all", ...) } \arguments{ \item{x}{A fitted model.} @@ -78,12 +59,17 @@ auxiliary parameters). Some model classes also allow rather uncommon options. These are: \itemize{ -\item \code{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} -\item \code{BGGM}: \code{"correlation"} and \code{"intercept"} -\item \code{BFBayesFactor}, \code{glmx}: \code{"extra"} -\item \code{averaging}:\code{"conditional"} and \code{"full"} -\item \code{mjoint}: \code{"survival"} +\item \strong{mhurdle}: \code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"} +\item \strong{BGGM}: \code{"correlation"} and \code{"intercept"} +\item \strong{BFBayesFactor}, \strong{glmx}: \code{"extra"} +\item \strong{averaging}:\code{"conditional"} and \code{"full"} +\item \strong{mjoint}: \code{"survival"} +\item \strong{mfx}: \code{"precision"}, \code{"marginal"} } + +For models of class \code{brmsfit} (package \strong{brms}), \code{component}, even more +options are possible for the \code{component} argument, which are not all +documented in detail here. } \examples{ diff --git a/man/n_parameters.Rd b/man/n_parameters.Rd index e20643797..fe5c02bdf 100644 --- a/man/n_parameters.Rd +++ b/man/n_parameters.Rd @@ -54,8 +54,9 @@ n_parameters(x, ...) count) non-estimable parameters (which may occur for models with rank-deficient model matrix).} -\item{effects}{Should number of parameters for fixed effects, random effects -or both be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should variables for fixed effects (\code{"fixed"}), random effects +(\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed models. May +be abbreviated.} \item{component}{Should total number of parameters, number parameters for the conditional model, the zero-inflated part of the model, the dispersion term diff --git a/pkgdown/_pkgdown.yaml b/pkgdown/_pkgdown.yaml index c90ac58e2..fdfc438c6 100644 --- a/pkgdown/_pkgdown.yaml +++ b/pkgdown/_pkgdown.yaml @@ -131,7 +131,7 @@ reference: - get_parameters.emmGrid - get_parameters.gamm - get_parameters.betamfx - - get_parameters.glmm + - get_parameters.glmmTMB - get_parameters.zeroinfl - get_parameters.betareg - get_parameters.htest