#' Heckman's two-step method
#'
#' @description
#' Estimate the classical Heckman model parameters by the two-step method.
#'
#' @param selection A formula for the selection equation.
#' @param outcome A formula for the outcome equation.
#' @param data A data frame containing the variables used in the model.
#'
#' @return A numeric vector with the two-step estimates.
#'
#' @importFrom Rdpack reprompt
#' @references Heckman, J. J. (1976). The common structure of statistical
#' models of truncation, sample selection and limited dependent variables and
#' a simple estimator for such models. \emph{Annals of Economic and Social
#' Measurement}, 5(4), 475-492.
#'
#' Heckman, J. J. (1979). Sample selection bias as a specification error.
#' \emph{Econometrica}, 47, 153-161.
#' @export
twostep <- function(selection, outcome, data = sys.frame(sys.parent())) {
  components <- extract_model_components(selection = selection, outcome = outcome, data = data)
  step2(components$YS, components$XS, components$YO, components$XO)
}
