diff --git a/DESCRIPTION b/DESCRIPTION index 7d61265..f175d6e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,3 +42,4 @@ Enhances: rstanarm VignetteBuilder: knitr Roxygen: list(markdown = TRUE) +RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index 61122ac..0ff33ff 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -50,6 +50,7 @@ importFrom(stats,as.formula) importFrom(stats,coef) importFrom(stats,coefficients) importFrom(stats,complete.cases) +importFrom(stats,contrasts) importFrom(stats,df.residual) importFrom(stats,ecdf) importFrom(stats,family) @@ -70,5 +71,7 @@ importFrom(stats,residuals) importFrom(stats,sd) importFrom(stats,terms) importFrom(stats,update) +importFrom(stats,update.formula) importFrom(stats,vcov) importFrom(stats,weighted.mean) +importFrom(utils,methods) diff --git a/R/simple_margins.R b/R/simple_margins.R index 5765fd0..baf96cf 100644 --- a/R/simple_margins.R +++ b/R/simple_margins.R @@ -185,7 +185,7 @@ sim_margins <- function(model, pred, modx, mod2 = NULL, modx.values = NULL, at_list[[mod2]] <- mod2vals2 } - design <- if ("svyglm" %in% class(model)) model$survey.design else NULL + design <- if (inherits(model, "svyglm")) model$survey.design else NULL # Get the margins suppressWarnings({ # can't have confusing warnings from margins @@ -274,7 +274,7 @@ print.sim_margins <- function(x, ...) { m <- ss$slopes[[j]] - if (class(x$mod2.values) != "character") { + if (inherits(x$mod2.values, "character")) { m[x$mod2] <- num_print(m[x$mod2], x$digits) } @@ -312,7 +312,7 @@ print.sim_margins <- function(x, ...) { for (i in seq_along(x$modx.values)) { - if (class(x$modx.values) != "character") { + if (inherits(x$modx.values, "character")) { m[x$modx] <- num_print(m[x$modx], digits = x$digits) } @@ -398,7 +398,7 @@ tidy.sim_margins <- function(x, conf.level = .95, ...) { base$conf.high <- all_slopes[,make_ci_labs(conf.level)[[2]]] } else { # If not, calculate them alpha <- (1 - conf.level) / 2 - crit_t <- if (class(x$mods[[1]]) == "lm") { + crit_t <- if (inherits(x$mods[[1]], "lm")) { abs(qt(alpha, df = df.residual(x$mods[[1]]))) } else { abs(qnorm(alpha)) diff --git a/R/simple_slopes.R b/R/simple_slopes.R index aad76e7..c1b04ca 100644 --- a/R/simple_slopes.R +++ b/R/simple_slopes.R @@ -118,7 +118,8 @@ #' sim_slopes(regmodel, pred = ell, modx = meals, mod2 = sch.wide) #' } #' -#' @importFrom stats coef coefficients lm predict sd update getCall vcov relevel +#' @importFrom stats coef coefficients lm predict sd update getCall vcov +#' @importFrom stats relevel contrasts #' @import jtools #' @export #' @@ -212,7 +213,7 @@ sim_slopes <- function(model, pred, modx, mod2 = NULL, modx.values = NULL, # Only keep the ones represented among the coefficients if (!is.null(attr(class(model), "package")) && "lme4" %in% attr(class(model), "package")) { - pred_names <- pred_names %just% names(fixef(model)) + pred_names <- pred_names %just% names(lme4::fixef(model)) } else { pred_names <- pred_names %just% names(coef(model)) } diff --git a/R/utils.R b/R/utils.R index ed380af..49217b5 100644 --- a/R/utils.R +++ b/R/utils.R @@ -165,8 +165,7 @@ cut2 <- function(x, cuts, m = 150, g, levels.mean = FALSE, "\nUpper endpoints:", paste(format(up, digits = 12), collapse = " ")) y <- structure(y, class = "factor", levels = labs) - } - else { + } else { if (minmax) { r <- range(x, na.rm = TRUE) if (r[1] < cuts[1]) @@ -289,6 +288,7 @@ j_update <- function(mod, formula = NULL, data = NULL, offset = NULL, # Looking for whether a method is defined for a given object (...) # getS3method() doesn't work for something like merMod because the string # "merMod" is not in the vector returned by class() +#' @importFrom utils methods check_method <- function(generic, ...) { ch <- deparse(substitute(generic)) f <- X <- function(x, ...) UseMethod("X")