Skip to content

Commit

Permalink
Namespace additions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-long committed Jan 8, 2024
1 parent bc8fca7 commit 8320559
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ Enhances:
rstanarm
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
8 changes: 4 additions & 4 deletions R/simple_margins.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions R/simple_slopes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down Expand Up @@ -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))
}
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 8320559

Please sign in to comment.