safe_model_matrix: Safe construction of model matrices
Description
Attempt to build model.matrix() with additional checks for
size and rank, and fall back to an intercept-only matrix on failure.
Usage
safe_model_matrix(formula, data, max_cols = 100)
Value
A numeric matrix suitable for downstream computations.
Arguments
- formula
A model formula.
- data
A data.frame.
- max_cols
Integer; warn if more than this many columns are produced.