R/methods_robustlmm.R

Defines functions get_predict.rlmerMod set_coef.rlmerMod

Documented in get_predict.rlmerMod set_coef.rlmerMod

#' @rdname set_coef
#' @export
set_coef.rlmerMod <- function(model, coefs, ...) {
    model@beta <- coefs
    model
}


#' @rdname get_predict
#' @export
get_predict.rlmerMod <- function(model,
                                 newdata = insight::get_data(model),
                                 type = "response",
                                 ...) {

    args <- list(...)
    # some predict methods raise warnings on unused arguments
    unused <- c("type", "normalize_dydx", "step_size", "numDeriv_method",
                "conf_level", "conf.level", "internal_call",
                "return_format", "vcov", "eps", "modeldata")
    args <- args[setdiff(names(args), unused)]
    args[["object"]] <- model
    args[["newdata"]] <- newdata
    out <- data.frame(rowid = seq_len(nrow(newdata)),
                      estimate = do.call("predict", args))
    return(out)
}

Try the marginaleffects package in your browser

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

marginaleffects documentation built on May 29, 2024, 4:03 a.m.