R/methods_dataframe.R

Defines functions set_coef.data.frame get_coef.data.frame

Documented in get_coef.data.frame set_coef.data.frame

#' @include get_coef.R
#' @rdname get_coef
#' @export
get_coef.data.frame <- function(model, ...) {
    checkmate::assert_data_frame(model)
    if (!"estimate" %in% colnames(model)) {
        insight::format_error("The model object is a data.frame but doesn't contain the column 'estimate'. Make sure these columns are present")
    }

    out <- model$estimate
    if ("term" %in% colnames(model)) {
        names(out) <- model$term
    } else {
        names(out) <- seq_along(out)
    }

    return(out)
}


#' @include set_coef.R
#' @rdname set_coef
#' @export
set_coef.data.frame = function(model, coefs, ...) {
  model$estimate = coefs
  return(model)
}

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.