From 260d2e5cfb2627ad379aaf865bbdb46522757ffd Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Nov 2024 11:57:28 +0100 Subject: [PATCH] docs --- R/find_parameter_zi.R | 32 ++++++++++++++++---------------- R/find_predictors.R | 21 +++++++++++++-------- man/find_interactions.Rd | 13 ++++++------- man/find_parameters.Rd | 2 ++ man/find_parameters.zeroinfl.Rd | 18 +++--------------- man/find_predictors.Rd | 21 +++++++++++++-------- man/find_variables.Rd | 15 ++++++++------- man/get_data.Rd | 15 ++++++++------- man/get_parameters.Rd | 2 ++ man/get_parameters.betamfx.Rd | 13 ++++++------- man/get_parameters.betareg.Rd | 13 ++++++------- man/get_parameters.gamm.Rd | 13 ++++++------- man/get_parameters.zeroinfl.Rd | 13 ++++++------- 13 files changed, 95 insertions(+), 96 deletions(-) diff --git a/R/find_parameter_zi.R b/R/find_parameter_zi.R index 920a0f6e76..d8759c1264 100644 --- a/R/find_parameter_zi.R +++ b/R/find_parameter_zi.R @@ -15,18 +15,17 @@ #' - `conditional`, the "fixed effects" part from the model. #' - `zero_inflated`, the "fixed effects" part from the zero-inflation #' component of the model. +#' - Special models are `mhurdle`, which also can have the components +#' `infrequent_purchase`, `ip`, and `auxiliary`. #' #' @examples #' data(mtcars) #' m <- lm(mpg ~ wt + cyl + vs, data = mtcars) #' find_parameters(m) #' @export -find_parameters.zeroinfl <- function(x, - component = c("all", "conditional", "zi", "zero_inflated"), - flatten = FALSE, - ...) { +find_parameters.zeroinfl <- function(x, component = "all", flatten = FALSE, ...) { cf <- names(stats::coef(x)) - component <- match.arg(component) + component <- validate_argument(component, c("all", "conditional", "zi", "zero_inflated")) l <- compact_list(list( conditional = cf[startsWith(cf, "count_")], @@ -50,12 +49,9 @@ find_parameters.zerotrunc <- find_parameters.zeroinfl #' @export -find_parameters.zcpglm <- function(x, - component = c("all", "conditional", "zi", "zero_inflated"), - flatten = FALSE, - ...) { +find_parameters.zcpglm <- function(x, component = "all", flatten = FALSE, ...) { cf <- stats::coef(x) - component <- match.arg(component) + component <- validate_argument(component, c("all", "conditional", "zi", "zero_inflated")) l <- compact_list(list( conditional = names(cf$tweedie), @@ -72,15 +68,19 @@ find_parameters.zcpglm <- function(x, } -#' @rdname find_parameters.zeroinfl #' @export -find_parameters.mhurdle <- function(x, - component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", "auxiliary"), - flatten = FALSE, - ...) { - component <- match.arg(component) +find_parameters.mhurdle <- function(x, component = "all", flatten = FALSE, ...) { + component <- validate_argument( + component, + c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", "auxiliary", "distributional") + ) cf <- stats::coef(x) + # handle alias + if (component == "distributional") { + component <- "auxiliary" + } + cond_pars <- which(startsWith(names(cf), "h2.")) zi_pars <- which(startsWith(names(cf), "h1.")) ip_pars <- which(startsWith(names(cf), "h3.")) diff --git a/R/find_predictors.R b/R/find_predictors.R index 06359f6c2a..d8abe5c393 100644 --- a/R/find_predictors.R +++ b/R/find_predictors.R @@ -10,13 +10,12 @@ #' @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 component Should all predictor variables, predictor variables for the -#' conditional model, the zero-inflated part of the model, the dispersion -#' term or the instrumental variables be returned? Applies to models -#' with zero-inflated and/or dispersion formula, or to models with instrumental -#' variable (so called fixed-effects regressions). May be abbreviated. Note that the -#' *conditional* component is also called *count* or *mean* -#' component, depending on the model. +#' @param component Indicates which model component shoild 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 +#' instrumental variables be returned? See section _Model Components_ for futher +#' details. May be abbreviated. Note that the *conditional* component is also +#' called *count* or *mean* component, depending on the model. #' @param flatten Logical, if `TRUE`, the values are returned #' as character vector, not as list. Duplicated values are removed. #' @param verbose Toggle warnings. @@ -47,6 +46,8 @@ #' auxiliary parameters). #' - `"distributional"` (or `"auxiliary"`): components like `sigma`, `dispersion`, #' `beta` or `precision` (and other auxiliary parameters) are returned. +#' - Special models are `mhurdle`, which also can have the components +#' `"infrequent_purchase"`, `"ip"`, and `"auxiliary"`. #' #' @section Parameters, Variables, Predictors and Terms: #' There are four functions that return information about the variables in a @@ -74,7 +75,7 @@ #' #' @return A list of character vectors that represent the name(s) of the #' predictor variables. Depending on the combination of the arguments -#' `effects` and `component`, the returned list has following elements: +#' `effects` and `component`, the returned list can have following elements: #' #' - `conditional`, the "fixed effects" terms from the model #' - `random`, the "random effects" terms from the model @@ -87,6 +88,10 @@ #' the instrumental variables #' - `correlation`, for models with correlation-component like `gls`, the #' variables used to describe the correlation structure +#' - `nonlinear`, for non-linear models (like models of class `nlmerMod` or +#' `nls`), the staring estimates for the nonlinear parameters +#' - `smooth_terms` returns smooth terms, only applies to GAMs (or similar +#' models that may contain smooth terms) #' #' @examples #' data(mtcars) diff --git a/man/find_interactions.Rd b/man/find_interactions.Rd index a39447300a..c7eb0a71ee 100644 --- a/man/find_interactions.Rd +++ b/man/find_interactions.Rd @@ -13,13 +13,12 @@ find_interactions( \arguments{ \item{x}{A fitted model.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \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.Rd b/man/find_parameters.Rd index 1a8138acf6..ffbb312192 100644 --- a/man/find_parameters.Rd +++ b/man/find_parameters.Rd @@ -65,6 +65,8 @@ 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. +\item Special models are \code{mhurdle}, which also can have the components +\code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"}. } } diff --git a/man/find_parameters.zeroinfl.Rd b/man/find_parameters.zeroinfl.Rd index e54914225c..438396cebf 100644 --- a/man/find_parameters.zeroinfl.Rd +++ b/man/find_parameters.zeroinfl.Rd @@ -2,23 +2,9 @@ % Please edit documentation in R/find_parameter_zi.R \name{find_parameters.zeroinfl} \alias{find_parameters.zeroinfl} -\alias{find_parameters.mhurdle} \title{Find names of model parameters from zero-inflated models} \usage{ -\method{find_parameters}{zeroinfl}( - x, - component = c("all", "conditional", "zi", "zero_inflated"), - flatten = FALSE, - ... -) - -\method{find_parameters}{mhurdle}( - x, - component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", - "auxiliary"), - flatten = FALSE, - ... -) +\method{find_parameters}{zeroinfl}(x, component = "all", flatten = FALSE, ...) } \arguments{ \item{x}{A fitted model.} @@ -51,6 +37,8 @@ elements: \item \code{conditional}, the "fixed effects" part from the model. \item \code{zero_inflated}, the "fixed effects" part from the zero-inflation component of the model. +\item Special models are \code{mhurdle}, which also can have the components +\code{infrequent_purchase}, \code{ip}, and \code{auxiliary}. } } \description{ diff --git a/man/find_predictors.Rd b/man/find_predictors.Rd index 7deb124814..4fbb6a8cb7 100644 --- a/man/find_predictors.Rd +++ b/man/find_predictors.Rd @@ -24,13 +24,12 @@ find_predictors(x, ...) \item{effects}{Should variables for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} @@ -40,7 +39,7 @@ as character vector, not as list. Duplicated values are removed.} \value{ A list of character vectors that represent the name(s) of the predictor variables. Depending on the combination of the arguments -\code{effects} and \code{component}, the returned list has following elements: +\code{effects} and \code{component}, the returned list can have following elements: \itemize{ \item \code{conditional}, the "fixed effects" terms from the model \item \code{random}, the "random effects" terms from the model @@ -53,6 +52,10 @@ component of the model the instrumental variables \item \code{correlation}, for models with correlation-component like \code{gls}, the variables used to describe the correlation structure +\item \code{nonlinear}, for non-linear models (like models of class \code{nlmerMod} or +\code{nls}), the staring estimates for the nonlinear parameters +\item \code{smooth_terms} returns smooth terms, only applies to GAMs (or similar +models that may contain smooth terms) } } \description{ @@ -89,6 +92,8 @@ 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. +\item Special models are \code{mhurdle}, which also can have the components +\code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"}. } } diff --git a/man/find_variables.Rd b/man/find_variables.Rd index c55d059ec0..b4f5583eb3 100644 --- a/man/find_variables.Rd +++ b/man/find_variables.Rd @@ -18,13 +18,12 @@ find_variables( \item{effects}{Should variables for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{flatten}{Logical, if \code{TRUE}, the values are returned as character vector, not as list. Duplicated values are removed.} @@ -84,6 +83,8 @@ 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. +\item Special models are \code{mhurdle}, which also can have the components +\code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"}. } } diff --git a/man/get_data.Rd b/man/get_data.Rd index 777d0aaf3a..b4c852d325 100644 --- a/man/get_data.Rd +++ b/man/get_data.Rd @@ -62,13 +62,12 @@ that have no missing data in the variables used for model fitting.} effects (\code{"random"}) or both (\code{"all"}) be returned? Only applies to mixed or gee models.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{shape}{Return long or wide data? Only applicable in repeated measures designs.} @@ -119,6 +118,8 @@ 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. +\item Special models are \code{mhurdle}, which also can have the components +\code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"}. } } diff --git a/man/get_parameters.Rd b/man/get_parameters.Rd index cc6ac327c6..a7ab2f7019 100644 --- a/man/get_parameters.Rd +++ b/man/get_parameters.Rd @@ -75,6 +75,8 @@ 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. +\item Special models are \code{mhurdle}, which also can have the components +\code{"infrequent_purchase"}, \code{"ip"}, and \code{"auxiliary"}. } } diff --git a/man/get_parameters.betamfx.Rd b/man/get_parameters.betamfx.Rd index 7304d44683..de51ee5b17 100644 --- a/man/get_parameters.betamfx.Rd +++ b/man/get_parameters.betamfx.Rd @@ -16,13 +16,12 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{...}{Currently not used.} } diff --git a/man/get_parameters.betareg.Rd b/man/get_parameters.betareg.Rd index 7c4ff61590..5c80932a17 100644 --- a/man/get_parameters.betareg.Rd +++ b/man/get_parameters.betareg.Rd @@ -48,13 +48,12 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{...}{Currently not used.} } diff --git a/man/get_parameters.gamm.Rd b/man/get_parameters.gamm.Rd index dfbe890beb..b708741349 100644 --- a/man/get_parameters.gamm.Rd +++ b/man/get_parameters.gamm.Rd @@ -23,13 +23,12 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{...}{Currently not used.} } diff --git a/man/get_parameters.zeroinfl.Rd b/man/get_parameters.zeroinfl.Rd index d997e7b3e8..71da5bb825 100644 --- a/man/get_parameters.zeroinfl.Rd +++ b/man/get_parameters.zeroinfl.Rd @@ -28,13 +28,12 @@ \arguments{ \item{x}{A fitted model.} -\item{component}{Should all predictor variables, predictor variables for the -conditional model, the zero-inflated part of the model, the dispersion -term or the instrumental variables be returned? Applies to models -with zero-inflated and/or dispersion formula, or to models with instrumental -variable (so called fixed-effects regressions). May be abbreviated. Note that the -\emph{conditional} component is also called \emph{count} or \emph{mean} -component, depending on the model.} +\item{component}{Indicates which model component shoild 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 +instrumental variables be returned? See section \emph{Model Components} for futher +details. May be abbreviated. Note that the \emph{conditional} component is also +called \emph{count} or \emph{mean} component, depending on the model.} \item{...}{Currently not used.} }