makeXZy {oneinfl} | R Documentation |
Prepare Design Matrices and Response Vector
Description
Processes a model formula and a data frame to generate design matrices ('X' and 'Z') and a response vector ('y') for regression models, including support for complex formulas with '|' operators.
Usage
makeXZy(formula, df)
Arguments
formula |
A symbolic description of the model, where the left-hand side specifies the response variable and the right-hand side specifies predictors. Formulas can include a '|' operator to separate predictors for different components of a model. |
df |
A data frame containing the variables specified in the formula. |
Details
This function processes the formula to extract and construct: - 'X': The main design matrix. - 'Z': A secondary design matrix (if a '|' operator is used in the formula, separating components). - 'y': The response variable.
It handles cases where the formula specifies:
- Only the main component (e.g., y ~ x1 + x2
).
- A secondary component using the '|' operator (e.g., y ~ x1 + x2 | z1 + z2
).
Value
A list containing the following components:
X
A design matrix for the main predictors.
Z
A design matrix for additional predictors (e.g., for a secondary process in a two-component model).
y
The response vector extracted from the formula.
See Also
model.matrix
, model.frame
, model.response