View source: R/extract_model_components.R
| extract_model_components | R Documentation |
This internal utility function extracts key components—such as model frames, matrices,
and response variables—from formulas and a data set. It is used by models like
HeckmanCL, HeckmanGe, HeckmanSK, HeckmanBS, and HeckmantS.
Additionally, it can handle covariate matrices for modeling dispersion (sigma) and
correlation (rho) structures.
extract_model_components(
selection,
outcome,
data,
outcomeS = NULL,
outcomeC = NULL,
drop.levels = TRUE
)
selection |
A formula for the selection equation. |
outcome |
A formula for the outcome equation. |
data |
A data frame containing all variables. |
outcomeS |
Optional formula or matrix for the dispersion model ( |
outcomeC |
Optional formula or matrix for the correlation model ( |
drop.levels |
Logical. If |
If provided, outcomeS and outcomeC can be formulas or matrices for modeling
dispersion and correlation structures, respectively. The function ensures that the
selection equation response is binary.
A list with the following components:
XSModel matrix for the selection equation.
YSResponse vector for the selection equation.
NXSNumber of covariates in the selection model.
XOModel matrix for the outcome equation.
YOResponse vector for the outcome equation.
NXONumber of covariates in the outcome model.
MsigmaMatrix for the dispersion model (or NULL if not provided).
NENumber of covariates for the dispersion model (0 if not provided).
MrhoMatrix for the correlation model (or NULL if not provided).
NVNumber of covariates for the correlation model (0 if not provided).
YSLevelsFactor levels of the binary selection response.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.