File: methods_sampleSelection.R

package info (click to toggle)
r-cran-marginaleffects 0.32.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,784 kB
  • sloc: sh: 13; makefile: 8
file content (29 lines) | stat: -rw-r--r-- 812 bytes parent folder | download
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)
}