Skip to contents

Extract the model matrix (X) from a fitted model object.

Usage

# S3 method for spmod
model.matrix(object, ...)

Arguments

object

A fitted model object from splm() or spautor().

...

Other arguments. Not used (needed for generic consistency).

Value

The model matrix (of the fixed effects), whose rows represent observations and whose columns represent explanatory variables corresponding to each fixed effect.

Examples

spmod <- splm(z ~ water + tarp,
  data = caribou,
  spcov_type = "exponential", xcoord = x, ycoord = y
)
model.matrix(spmod)
#>    (Intercept) waterY tarpnone tarpshade
#> 1            1      1        0         0
#> 2            1      1        0         1
#> 3            1      1        1         0
#> 4            1      0        0         0
#> 5            1      0        0         1
#> 6            1      1        1         0
#> 7            1      0        0         0
#> 8            1      1        0         0
#> 9            1      1        0         1
#> 10           1      1        1         0
#> 11           1      1        0         0
#> 12           1      1        0         1
#> 13           1      1        1         0
#> 14           1      0        0         1
#> 15           1      0        1         0
#> 16           1      0        0         0
#> 17           1      0        0         1
#> 18           1      0        1         0
#> 19           1      1        0         1
#> 20           1      1        1         0
#> 21           1      0        1         0
#> 22           1      1        0         0
#> 23           1      0        0         0
#> 24           1      0        0         1
#> 25           1      0        1         0
#> 26           1      0        0         0
#> 27           1      0        0         1
#> 28           1      0        1         0
#> 29           1      1        0         0
#> 30           1      1        0         1
#> attr(,"assign")
#> [1] 0 1 2 2
#> attr(,"contrasts")
#> attr(,"contrasts")$water
#> [1] "contr.treatment"
#> 
#> attr(,"contrasts")$tarp
#> [1] "contr.treatment"
#>