Skip to content

Commit

Permalink
remove redundant comment
Browse files Browse the repository at this point in the history
`check_if_installed()` is descriptive enough to convey this
  • Loading branch information
IndrajeetPatil committed Jul 26, 2024
1 parent 01f30b6 commit 738cd2e
Show file tree
Hide file tree
Showing 22 changed files with 7 additions and 49 deletions.
6 changes: 2 additions & 4 deletions R/compute_variances.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
return(NULL)
}

# installed?

check_if_installed("lme4", reason = "to compute variances for mixed models")

if (inherits(model, "lme")) {
Expand Down Expand Up @@ -420,7 +420,6 @@
# cpglmm
# ---------------------------
} else if (inherits(model, "cpglmm")) {
# installed?
check_if_installed("cplm")

mixed_effects_info <- list(
Expand Down Expand Up @@ -805,7 +804,7 @@
mu <- NA
} else {
if (inherits(model_null, "cpglmm")) {
check_if_installed("cplm") # installed?
check_if_installed("cplm")
null_fixef <- unname(cplm::fixef(model_null))
} else {
null_fixef <- unname(.collapse_cond(lme4::fixef(model_null)))
Expand Down Expand Up @@ -1158,7 +1157,6 @@
# undefined families / link-functions
# ----------------------------------------------
.variance_family_default <- function(model, mu, verbose) {
# installed?
check_if_installed("lme4")

tryCatch(
Expand Down
1 change: 0 additions & 1 deletion R/export_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ print.insight_table <- function(x, ...) {
group_by = NULL,
indent_groups = NULL,
indent_rows = NULL) {
# installed?
check_if_installed("gt")

if (is.null(align)) {
Expand Down
1 change: 0 additions & 1 deletion R/find_algorithm.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ find_algorithm.speedlm <- function(x, ...) {

#' @export
find_algorithm.blavaan <- function(x, ...) {
# installed?
check_if_installed("blavaan")

list(
Expand Down
3 changes: 0 additions & 3 deletions R/find_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ find_parameters.brmultinom <- find_parameters.multinom

#' @export
find_parameters.blavaan <- function(x, flatten = FALSE, ...) {
# installed?
check_if_installed("lavaan")

param_tab <- lavaan::parameterEstimates(x)
Expand Down Expand Up @@ -227,7 +226,6 @@ find_parameters.blavaan <- function(x, flatten = FALSE, ...) {

#' @export
find_parameters.lavaan <- function(x, flatten = FALSE, ...) {
# installed?
check_if_installed("lavaan")

pars <- get_parameters(x)
Expand Down Expand Up @@ -470,7 +468,6 @@ find_parameters.survreg <- function(x, flatten = FALSE, ...) {

#' @export
find_parameters.mle2 <- function(x, flatten = FALSE, ...) {
# installed?
check_if_installed("bbmle")

s <- bbmle::summary(x)
Expand Down
2 changes: 0 additions & 2 deletions R/find_parameters_mixed.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ find_parameters.coxme <- function(x,
effects = c("all", "fixed", "random"),
flatten = FALSE,
...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -378,7 +377,6 @@ find_parameters.lme <- function(x,
effects = c("all", "fixed", "random"),
flatten = FALSE,
...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down
1 change: 0 additions & 1 deletion R/get_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ get_df.emm_list <- function(x, ...) {

#' @export
get_df.mira <- function(x, type = "residual", verbose = TRUE, ...) {
# installed?
check_if_installed("mice")
type <- match.arg(tolower(type), choices = c("residual", "model", "normal", "wald", "any", "analytical"))
get_df(mice::pool(x), type, verbose = verbose, ...)
Expand Down
1 change: 0 additions & 1 deletion R/get_loglikelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ get_loglikelihood.list <- get_loglikelihood.lm

#' @export
get_loglikelihood.stanreg <- function(x, centrality = stats::median, ...) {
# installed?
check_if_installed("rstanarm")

# Get posterior distribution of logliks
Expand Down
1 change: 0 additions & 1 deletion R/get_modelmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ get_modelmatrix.betareg <- function(x, ...) {

#' @export
get_modelmatrix.cpglmm <- function(x, ...) {
# installed?
check_if_installed("cplm")
cplm::model.matrix(x, ...)
}
Expand Down
1 change: 0 additions & 1 deletion R/get_nested_lme_varcorr.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# It retrieves the variance-covariance matrix of random effects
# from nested lme-models.
.get_nested_lme_varcorr <- function(x) {
# installed?
check_if_installed("lme4")

vcor <- lme4::VarCorr(x)
Expand Down
5 changes: 1 addition & 4 deletions R/get_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ get_parameters.mipo <- function(x, ...) {

#' @export
get_parameters.mira <- function(x, ...) {
# installed?
check_if_installed("mice")
get_parameters(mice::pool(x), ...)
}
Expand Down Expand Up @@ -355,7 +354,6 @@ get_parameters.glht <- function(x, ...) {

#' @export
get_parameters.mle2 <- function(x, ...) {
# installed?
check_if_installed("bbmle")
s <- bbmle::summary(x)

Expand Down Expand Up @@ -594,7 +592,7 @@ get_parameters.blavaan <- function(x, summary = FALSE, standardize = FALSE, ...)
if (isTRUE(summary)) {
return(get_parameters.lavaan(x, standardize = standardize, ...))
}
# installed?

check_if_installed("lavaan")
check_if_installed("blavaan")

Expand Down Expand Up @@ -635,7 +633,6 @@ get_parameters.blavaan <- function(x, summary = FALSE, standardize = FALSE, ...)

#' @export
get_parameters.lavaan <- function(x, standardize = FALSE, ...) {
# installed?
check_if_installed("lavaan")

if (standardize) {
Expand Down
2 changes: 0 additions & 2 deletions R/get_parameters_bayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ get_parameters.BGGM <- function(x,
component = c("correlation", "conditional", "intercept", "all"),
summary = FALSE, centrality = "mean",
...) {
# installed?
# check_if_installed("BGGM")
#
# out <- as.data.frame(BGGM::posterior_samples(x))
Expand Down Expand Up @@ -110,7 +109,6 @@ get_parameters.BFBayesFactor <- function(x,
summary = FALSE,
centrality = "mean",
...) {
# installed?
check_if_installed("BayesFactor")

effects <- match.arg(effects)
Expand Down
1 change: 0 additions & 1 deletion R/get_parameters_emmeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ get_parameters.emm_list <- function(x, summary = FALSE, ...) {


.clean_emmeans_draws <- function(x, ...) {
# installed?
check_if_installed("emmeans")

if (!is.null(attributes(x)$misc$predict.type) && attributes(x)$misc$predict.type != "none") {
Expand Down
9 changes: 0 additions & 9 deletions R/get_parameters_mixed.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ get_parameters.glmm <- function(x, effects = c("all", "fixed", "random"), ...) {
#' @rdname get_parameters.glmm
#' @export
get_parameters.coxme <- function(x, effects = c("fixed", "random"), ...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -115,7 +114,6 @@ get_parameters.wbm <- function(x, effects = c("fixed", "random"), ...) {

text_remove_backticks(out)
} else {
# installed?
check_if_installed("lme4")
lme4::ranef(x)
}
Expand All @@ -135,7 +133,6 @@ get_parameters.nlmerMod <- function(x,
effects = c("fixed", "random"),
component = c("all", "conditional", "nonlinear"),
...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -188,7 +185,6 @@ get_parameters.nlmerMod <- function(x,
#' @rdname get_parameters.glmm
#' @export
get_parameters.merMod <- function(x, effects = c("fixed", "random"), ...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -251,7 +247,6 @@ get_parameters.merModList <- function(x, ...) {

#' @export
get_parameters.HLfit <- function(x, effects = c("fixed", "random"), ...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -315,7 +310,6 @@ get_parameters.sem <- function(x, effects = c("fixed", "random"), ...) {

#' @export
get_parameters.cpglmm <- function(x, effects = c("fixed", "random"), ...) {
# installed?
check_if_installed("cplm")

effects <- match.arg(effects)
Expand Down Expand Up @@ -346,7 +340,6 @@ get_parameters.cpglmm <- function(x, effects = c("fixed", "random"), ...) {

#' @export
get_parameters.mixed <- function(x, effects = c("fixed", "random"), ...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -379,7 +372,6 @@ get_parameters.mixed <- function(x, effects = c("fixed", "random"), ...) {
get_parameters.MixMod <- function(x,
effects = c("fixed", "random"),
component = c("all", "conditional", "zi", "zero_inflated", "dispersion"), ...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down Expand Up @@ -456,7 +448,6 @@ get_parameters.MixMod <- function(x,
get_parameters.glmmTMB <- function(x,
effects = c("fixed", "random"),
component = c("all", "conditional", "zi", "zero_inflated", "dispersion"), ...) {
# installed?
check_if_installed("lme4")

effects <- match.arg(effects)
Expand Down
1 change: 0 additions & 1 deletion R/get_predicted_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ get_predicted_ci.bracl <- get_predicted_ci.mlm
}
if (length(ci) == 1) names(out) <- c("Parameter", "CI_low", "CI_high")
} else {
# installed?
check_if_installed(c("bayestestR", "datawizard"))
out <- as.data.frame(bayestestR::ci(as.data.frame(t(iter)), ci = ci, method = ci_method))
if (length(ci) > 1L) out <- datawizard::reshape_ci(out)
Expand Down
3 changes: 0 additions & 3 deletions R/get_priors.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ get_priors <- function(x, ...) {

#' @export
get_priors.stanreg <- function(x, verbose = TRUE, ...) {
# installed?
check_if_installed("rstanarm")

ps <- rstanarm::prior_summary(x)
Expand Down Expand Up @@ -119,7 +118,6 @@ get_priors.stanreg <- function(x, verbose = TRUE, ...) {

#' @export
get_priors.stanmvreg <- function(x, ...) {
# installed?
check_if_installed("rstanarm")


Expand Down Expand Up @@ -581,7 +579,6 @@ get_priors.BFBayesFactor <- function(x, ...) {

#' @export
get_priors.blavaan <- function(x, ...) {
# installed?
check_if_installed("lavaan")


Expand Down
5 changes: 0 additions & 5 deletions R/get_statistic.R
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,6 @@ get_statistic.selection <- function(x, component = "all", ...) {

#' @export
get_statistic.lavaan <- function(x, ...) {
# installed?
check_if_installed("lavaan")

params <- lavaan::parameterEstimates(x)
Expand Down Expand Up @@ -1790,7 +1789,6 @@ get_statistic.wbgee <- get_statistic.wbm

#' @export
get_statistic.cpglmm <- function(x, ...) {
# installed?
check_if_installed("cplm")

stats <- cplm::summary(x)$coefs
Expand Down Expand Up @@ -1835,7 +1833,6 @@ get_statistic.sem <- function(x, ...) {

#' @export
get_statistic.cpglm <- function(x, ...) {
# installed?
check_if_installed("cplm")

junk <- utils::capture.output(stats <- cplm::summary(x)$coefficients) # nolint
Expand All @@ -1856,7 +1853,6 @@ get_statistic.cpglm <- function(x, ...) {

#' @export
get_statistic.zcpglm <- function(x, component = "all", ...) {
# installed?
check_if_installed("cplm")

component <- match.arg(component, choices = c("all", "conditional", "zi", "zero_inflated"))
Expand Down Expand Up @@ -2382,7 +2378,6 @@ get_statistic.DirichletRegModel <- function(x, component = "all", ...) {

#' @export
get_statistic.glimML <- function(x, ...) {
# installed?
check_if_installed("aod")

parms <- get_parameters(x)
Expand Down
6 changes: 3 additions & 3 deletions R/get_varcov.R
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ get_varcov.zcpglm <- function(x,
.check_get_varcov_dots(x, ...)
component <- match.arg(component)

# installed?

check_if_installed("cplm")

vc <- cplm::vcov(x)
Expand Down Expand Up @@ -957,7 +957,7 @@ get_varcov.feis <- function(x, verbose = TRUE, ...) {
#' @export
get_varcov.glimML <- function(x, verbose = TRUE, ...) {
.check_get_varcov_dots(x, ...)
# installed?

check_if_installed("aod")

vc <- aod::vcov(x)
Expand All @@ -968,7 +968,7 @@ get_varcov.glimML <- function(x, verbose = TRUE, ...) {
#' @export
get_varcov.vglm <- function(x, verbose = TRUE, ...) {
.check_get_varcov_dots(x, ...)
# installed?

check_if_installed("VGAM")
vc <- VGAM::vcov(x)
.process_vcov(vc, verbose, ...)
Expand Down
1 change: 0 additions & 1 deletion R/link_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ link_function.mipo <- function(x, ...) {

#' @export
link_function.mira <- function(x, ...) {
# installed?
check_if_installed("mice")
link_function(mice::pool(x), ...)
}
Expand Down
2 changes: 0 additions & 2 deletions R/link_inverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ link_inverse.mipo <- function(x, ...) {

#' @export
link_inverse.mira <- function(x, ...) {
# installed?
check_if_installed("mice")
link_inverse(mice::pool(x), ...)
}
Expand Down Expand Up @@ -758,7 +757,6 @@ link_inverse.mira <- function(x, ...) {
if (is.null(link)) link <- "log"

if (is.numeric(link)) {
# installed?
check_if_installed("statmod")
statmod::tweedie(link.power = link)
} else {
Expand Down
1 change: 0 additions & 1 deletion R/model_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,6 @@ model_info.svy2lme <- function(x, verbose = TRUE, ...) {

#' @export
model_info.glmmTMB <- function(x, ...) {
# installed?
check_if_installed("lme4")

faminfo <- stats::family(x)
Expand Down
2 changes: 1 addition & 1 deletion R/n_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ n_parameters.logitr <- function(x, effects = c("all", "fixed", "random"), ...) {
#' @export
n_parameters.lavaan <- function(x, ...) {
# TODO
# installed?

# check_if_installed("lavaan")
# lavaan::fitmeasures(x)[["npar"]]
}
Expand Down
1 change: 0 additions & 1 deletion R/utils_model_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@


.classify_BFBayesFactor <- function(x) {
# installed?
check_if_installed("BayesFactor")

if (inherits(x@denominator, "BFcorrelation")) {
Expand Down

0 comments on commit 738cd2e

Please sign in to comment.