Grab a matrix of fixed effects from a model object

grab_design_matrix(data, rhs_formula, ...)

Arguments

data

the data from which to extract the matrix

rhs_formula

the right hand side of a model formula

...

Can be used to pass xlev to model.frame

Value

a model.matrix

Examples

# Create a "desigm" matrix for the first ten rows of iris data
fit <- lm(Sepal.Width ~ Petal.Width, data = iris)
grab_design_matrix(
  data = iris[1:10, ],
  grab_fixed_formula(fit))
#>    (Intercept) Petal.Width
#> 1            1         0.2
#> 2            1         0.2
#> 3            1         0.2
#> 4            1         0.2
#> 5            1         0.2
#> 6            1         0.4
#> 7            1         0.3
#> 8            1         0.2
#> 9            1         0.2
#> 10           1         0.1
#> attr(,"assign")
#> [1] 0 1