1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
# TODO: heckit standard errors are not available because `vcov` is block diagonal with NAs
#' @rdname get_coef
#' @export
get_coef.selection <- function(model, ...) {
if ("coefficients" %in% names(model)) {
out <- model$coefficients
} else if ("estimate" %in% names(model)) {
out <- model$estimate
} else {
stop("Model does not have coefficients or estimates.")
}
return(out)
}
#' @rdname set_coef
#' @export
set_coef.selection <- function(model, coefs, ...) {
# sampleSelection::selection
if ("coefficients" %in% names(model)) {
model[["coefficients"]] <- coefs
} else if ("estimate" %in% names(model)) {
model[["estimate"]] <- coefs
} else {
stop("Model does not have coefficients or estimates.")
}
return(model)
}
|