R/methods_sampleSelection.R

Defines functions set_coef.selection get_coef.selection

Documented in get_coef.selection set_coef.selection

# TODO: heckit standard errors are not available because `vcov` is block diagonal with NAs


#' @rdname get_coef
#' @export
get_coef.selection <- function(model, ...) {
    # sampleSelection::selection
    if (as.list(model$call)[[1]] == "selection") {
        out <- model$estimate
    # sampleSelection::heckit
    } else if (as.list(model$call)[[1]] == "heckit") {
        out <- model$coefficients
    }
    return(out)
}


#' @rdname set_coef
#' @export
set_coef.selection <- function(model, coefs, ...) {
    # sampleSelection::selection
    if (as.list(model$call)[[1]] == "selection") {
        model[["estimate"]] <- coefs
    # sampleSelection::heckit
    } else if (as.list(model$call)[[1]] == "heckit") {
        model[["coefficients"]] <- 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.