diff --git a/R/find_parameters_mixed.R b/R/find_parameters_mixed.R index 6bf833fcc..6ff7e02b6 100644 --- a/R/find_parameters_mixed.R +++ b/R/find_parameters_mixed.R @@ -144,14 +144,11 @@ find_parameters.nlmerMod <- function(x, effects = "all", component = "all", flat } -#' @rdname find_parameters.glmmTMB #' @export -find_parameters.hglm <- function(x, - effects = c("all", "fixed", "random"), - component = c("all", "conditional", "dispersion"), - flatten = FALSE, - ...) { - effects <- match.arg(effects) +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")) + fe <- x$fixef re <- x$ranef @@ -173,13 +170,9 @@ find_parameters.hglm <- function(x, } -#' @rdname find_parameters.glmmTMB #' @export -find_parameters.merMod <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { - effects <- match.arg(effects) +find_parameters.merMod <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) # installed check_if_installed("lme4") @@ -207,21 +200,15 @@ find_parameters.rlmerMod <- find_parameters.merMod find_parameters.glmmadmb <- find_parameters.merMod #' @export -find_parameters.merModList <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { - effects <- match.arg(effects) +find_parameters.merModList <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) find_parameters(x[[1]], effects = effects, flatten = flatten, ...) } #' @export -find_parameters.svy2lme <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { - effects <- match.arg(effects) +find_parameters.svy2lme <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) # we extract random effects only when really necessary, to save # computational time. In particular model with large sample and @@ -241,11 +228,8 @@ find_parameters.svy2lme <- function(x, #' @export -find_parameters.HLfit <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { - effects <- match.arg(effects) +find_parameters.HLfit <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) # installed check_if_installed("lme4") @@ -269,16 +253,13 @@ find_parameters.HLfit <- function(x, #' @export -find_parameters.sem <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.sem <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) + if (!.is_semLme(x)) { return(NULL) } - effects <- match.arg(effects) - l <- compact_list(list( conditional = names(x$coef), random = colnames(x$ranef) @@ -289,15 +270,11 @@ find_parameters.sem <- function(x, #' @export -find_parameters.cpglmm <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.cpglmm <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) # installed check_if_installed("cplm") - effects <- match.arg(effects) - # we extract random effects only when really necessary, to save # computational time. In particular model with large sample and # many random effects groups may take some time to return random effects @@ -316,14 +293,10 @@ find_parameters.cpglmm <- function(x, #' @export -find_parameters.coxme <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.coxme <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) check_if_installed("lme4") - effects <- match.arg(effects) - if (effects == "fixed") { l <- list(conditional = names(lme4::fixef(x))) } else { @@ -342,15 +315,11 @@ find_parameters.coxme <- function(x, #' @export -find_parameters.mixed <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.mixed <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) # installed check_if_installed("lme4") - effects <- match.arg(effects) - if (effects == "fixed") { l <- list(conditional = names(lme4::fixef(x$full_model))) } else { @@ -365,14 +334,10 @@ find_parameters.mixed <- function(x, #' @export -find_parameters.lme <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.lme <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) check_if_installed("lme4") - effects <- match.arg(effects) - if (effects == "fixed") { l <- list(conditional = names(lme4::fixef(x))) } else { @@ -394,11 +359,9 @@ find_parameters.lme <- function(x, #' @export -find_parameters.glmm <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { - effects <- match.arg(effects) +find_parameters.glmm <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) + s <- summary(x) fe_params <- rownames(s$coefmat) re_params <- rownames(s$nucoefmat) @@ -413,16 +376,14 @@ find_parameters.glmm <- function(x, #' @export -find_parameters.BBmm <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.BBmm <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) + l <- compact_list(list( conditional = rownames(x$fixed.coef), random = x$namesRand )) - effects <- match.arg(effects) .filter_parameters(l, effects = effects, flatten = flatten, @@ -432,16 +393,14 @@ find_parameters.BBmm <- function(x, #' @export -find_parameters.glimML <- function(x, - effects = c("all", "fixed", "random"), - flatten = FALSE, - ...) { +find_parameters.glimML <- function(x, effects = "all", flatten = FALSE, ...) { + effects <- validate_argument(effects, c("all", "fixed", "random")) + l <- compact_list(list( conditional = names(x@fixed.param), random = names(x@random.param) )) - effects <- match.arg(effects) .filter_parameters(l, effects = effects, flatten = flatten, diff --git a/man/find_parameters.glmmTMB.Rd b/man/find_parameters.glmmTMB.Rd index 5e005d174..37fb4a0ad 100644 --- a/man/find_parameters.glmmTMB.Rd +++ b/man/find_parameters.glmmTMB.Rd @@ -2,21 +2,9 @@ % Please edit documentation in R/find_parameters_mixed.R \name{find_parameters.glmmTMB} \alias{find_parameters.glmmTMB} -\alias{find_parameters.hglm} -\alias{find_parameters.merMod} \title{Find names of model parameters from mixed models} \usage{ \method{find_parameters}{glmmTMB}(x, effects = "all", component = "all", flatten = FALSE, ...) - -\method{find_parameters}{hglm}( - x, - effects = c("all", "fixed", "random"), - component = c("all", "conditional", "dispersion"), - flatten = FALSE, - ... -) - -\method{find_parameters}{merMod}(x, effects = c("all", "fixed", "random"), flatten = FALSE, ...) } \arguments{ \item{x}{A fitted model.}