diff --git a/R/methods_cplm.R b/R/methods_cplm.R index ad8efa25f..aa0fbf91d 100644 --- a/R/methods_cplm.R +++ b/R/methods_cplm.R @@ -18,6 +18,43 @@ #' @seealso [insight::standardize_names()] to rename #' columns into a consistent, standardized naming scheme. #' +#' @section Model components: +#' Possible values for the `component` argument depend on the model class. +#' Following are valid options: +#' - `"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. +#' - `"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. +#' - `"smooth_terms"`: returns smooth terms, only applies to GAMs (or similar +#' models that may contain smooth terms). +#' - `"zero_inflated"` (or `"zi"`): returns the zero-inflation component. +#' - `"dispersion"`: returns the dispersion model component. This is common +#' for models with zero-inflation or that can model the dispersion parameter. +#' - `"instruments"`: for instrumental-variable or some fixed effects regression, +#' returns the instruments. +#' - `"nonlinear"`: for non-linear models (like models of class `nlmerMod` or +#' `nls`), returns staring estimates for the nonlinear parameters. +#' - `"correlation"`: for models with correlation-component, like `gls`, the +#' variables used to describe the correlation structure are returned. +#' +#' **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"` +#' - **mfx**: `"precision"`, `"marginal"` +#' - **betareg**, **DirichletRegModel**: `"precision"` +#' - **mvord**: `"thresholds"` and `"correlation"` +#' - **clm2**: `"scale"` +#' +#' 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. +#' #' @examples #' library(parameters) #' if (require("pscl")) { @@ -32,7 +69,7 @@ model_parameters.zcpglm <- function(model, ci = 0.95, bootstrap = FALSE, iterations = 1000, - component = c("all", "conditional", "zi", "zero_inflated"), + component = "all", standardize = NULL, exponentiate = FALSE, p_adjust = NULL, @@ -42,7 +79,7 @@ model_parameters.zcpglm <- function(model, drop = NULL, verbose = TRUE, ...) { - component <- match.arg(component) + component <- insight::validate_argument(component, c("all", "conditional", "zi", "zero_inflated")) # fix argument, if model has no zi-part if (!insight::model_info(model, verbose = FALSE)$is_zero_inflated && component != "conditional") { diff --git a/R/methods_mhurdle.R b/R/methods_mhurdle.R index 47775b8c2..8d6a97f8c 100644 --- a/R/methods_mhurdle.R +++ b/R/methods_mhurdle.R @@ -1,15 +1,17 @@ -#' @rdname model_parameters.zcpglm #' @export model_parameters.mhurdle <- function(model, ci = 0.95, - component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", "auxiliary"), + component = "all", exponentiate = FALSE, p_adjust = NULL, keep = NULL, drop = NULL, verbose = TRUE, ...) { - component <- match.arg(component) + component <- insight::validate_argument( + component, + c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", "auxiliary") + ) params <- .model_parameters_generic( model, diff --git a/man/model_parameters.zcpglm.Rd b/man/model_parameters.zcpglm.Rd index d7f14b755..98e3786d4 100644 --- a/man/model_parameters.zcpglm.Rd +++ b/man/model_parameters.zcpglm.Rd @@ -1,8 +1,7 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/methods_cplm.R, R/methods_mhurdle.R +% Please edit documentation in R/methods_cplm.R \name{model_parameters.zcpglm} \alias{model_parameters.zcpglm} -\alias{model_parameters.mhurdle} \title{Parameters from Zero-Inflated Models} \usage{ \method{model_parameters}{zcpglm}( @@ -10,7 +9,7 @@ ci = 0.95, bootstrap = FALSE, iterations = 1000, - component = c("all", "conditional", "zi", "zero_inflated"), + component = "all", standardize = NULL, exponentiate = FALSE, p_adjust = NULL, @@ -21,19 +20,6 @@ verbose = TRUE, ... ) - -\method{model_parameters}{mhurdle}( - model, - ci = 0.95, - component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", - "auxiliary"), - exponentiate = FALSE, - p_adjust = NULL, - keep = NULL, - drop = NULL, - verbose = TRUE, - ... -) } \arguments{ \item{model}{A model with zero-inflation component.} @@ -148,6 +134,49 @@ A data frame of indices related to the model's parameters. Parameters from zero-inflated models (from packages like \strong{pscl}, \strong{cplm} or \strong{countreg}). } +\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. +} + +\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"} +\item \strong{betareg}, \strong{DirichletRegModel}: \code{"precision"} +\item \strong{mvord}: \code{"thresholds"} and \code{"correlation"} +\item \strong{clm2}: \code{"scale"} +} + +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{ library(parameters) if (require("pscl")) {