R/methods.R

Defines functions coef.comparisons vcov.comparisons

#' @noRd
#' @export
vcov.comparisons <- function(object, ...) {
    attr(object, "jacobian") %*% attr(object, "vcov") %*% t(attr(object, "jacobian"))
}


#' @noRd
#' @export
vcov.predictions <- vcov.comparisons


#' @noRd
#' @export
vcov.hypotheses <- vcov.comparisons


#' @noRd
#' @export
vcov.slopes <- vcov.comparisons


#' @noRd
#' @export
vcov.marginalmeans <- vcov.comparisons


#' @export
#' @noRd
coef.comparisons <- function(object, ...) {
  if (!is.null(object$estimate)) {
    out <- object$estimate
    if (is.null(names(out))) {
      lab <- tryCatch(get_term_labels(object), error = function(e) NULL)
      if (length(lab) == length(out)) {
        out <- stats::setNames(out, lab)
      }
    }
    return(out)
  } else {
    stop("The input object does not contain an 'estimate' element.")
  }
}


#' @export
#' @noRd
coef.slopes <- coef.comparisons


#' @export
#' @noRd
coef.marginalmeans <- coef.comparisons


#' @export
#' @noRd
coef.predictions <- coef.comparisons


#' @export
#' @noRd
coef.hypotheses <- coef.comparisons

Try the marginaleffects package in your browser

Any scripts or data that you put into this service are public.

marginaleffects documentation built on Oct. 20, 2023, 1:07 a.m.