diff --git a/R/select_parameters.R b/R/select_parameters.R index 0061fe552..93c697017 100644 --- a/R/select_parameters.R +++ b/R/select_parameters.R @@ -6,21 +6,17 @@ #' @param model A statistical model (of class `lm`, `glm`, or `merMod`). #' @param ... Arguments passed to or from other methods. #' -#' @details -#' \subsection{Classical lm and glm}{ -#' For frequentist GLMs, `select_parameters()` performs an AIC-based -#' stepwise selection. -#' } +#' @section Classical lm and glm: +#' For frequentist GLMs, `select_parameters()` performs an AIC-based stepwise +#' selection. #' -#' \subsection{Mixed models}{ -#' For mixed-effects models of class `merMod`, stepwise selection is -#' based on [cAIC4::stepcAIC()]. This step function -#' only searches the "best" model based on the random-effects structure, -#' i.e. `select_parameters()` adds or excludes random-effects until -#' the cAIC can't be improved further. -#' } +#' @section Mixed models: +#' For mixed-effects models of class `merMod`, stepwise selection is based on +#' [`cAIC4::stepcAIC()`]. This step function only searches the "best" model +#' based on the random-effects structure, i.e. `select_parameters()` adds or +#' excludes random-effects until the cAIC can't be improved further. #' -#' @examples +#' @examplesIf requireNamespace("lme4") #' model <- lm(mpg ~ ., data = mtcars) #' select_parameters(model) #' @@ -28,13 +24,11 @@ #' select_parameters(model) #' \donttest{ #' # lme4 ------------------------------------------- -#' if (require("lme4")) { -#' model <- lmer( -#' Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), -#' data = iris -#' ) -#' select_parameters(model) -#' } +#' model <- lme4::lmer( +#' Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), +#' data = iris +#' ) +#' select_parameters(model) #' } #' #' @return The model refitted with optimal number of parameters. diff --git a/man/select_parameters.Rd b/man/select_parameters.Rd index 733f6bfe5..12a880eac 100644 --- a/man/select_parameters.Rd +++ b/man/select_parameters.Rd @@ -41,21 +41,22 @@ The model refitted with optimal number of parameters. This function performs an automated selection of the 'best' parameters, updating and returning the "best" model. } -\details{ -\subsection{Classical lm and glm}{ -For frequentist GLMs, \code{select_parameters()} performs an AIC-based -stepwise selection. -} +\section{Classical lm and glm}{ -\subsection{Mixed models}{ -For mixed-effects models of class \code{merMod}, stepwise selection is -based on \code{\link[cAIC4:stepcAIC]{cAIC4::stepcAIC()}}. This step function -only searches the "best" model based on the random-effects structure, -i.e. \code{select_parameters()} adds or excludes random-effects until -the cAIC can't be improved further. +For frequentist GLMs, \code{select_parameters()} performs an AIC-based stepwise +selection. } + +\section{Mixed models}{ + +For mixed-effects models of class \code{merMod}, stepwise selection is based on +\code{\link[cAIC4:stepcAIC]{cAIC4::stepcAIC()}}. This step function only searches the "best" model +based on the random-effects structure, i.e. \code{select_parameters()} adds or +excludes random-effects until the cAIC can't be improved further. } + \examples{ +\dontshow{if (requireNamespace("lme4")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} model <- lm(mpg ~ ., data = mtcars) select_parameters(model) @@ -63,13 +64,11 @@ model <- lm(mpg ~ cyl * disp * hp * wt, data = mtcars) select_parameters(model) \donttest{ # lme4 ------------------------------------------- -if (require("lme4")) { - model <- lmer( - Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), - data = iris - ) - select_parameters(model) -} +model <- lme4::lmer( + Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), + data = iris +) +select_parameters(model) } - +\dontshow{\}) # examplesIf} }