makeXZy | R Documentation |
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.
makeXZy(formula, df)
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 |
df |
A data frame containing the variables specified in the formula. |
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
).
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.
model.matrix
, model.frame
, model.response
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.