R/model.matrix.R, R/model.matrix_glm.R
model.matrix.spmodel.RdExtract the model matrix (X) from a fitted model object.
# S3 method for class 'splm'
model.matrix(object, ...)
# S3 method for class 'spautor'
model.matrix(object, ...)
# S3 method for class 'spglm'
model.matrix(object, ...)
# S3 method for class 'spgautor'
model.matrix(object, ...)A fitted model object from splm(), spautor(), spglm(), or spgautor().
Other arguments. Not used (needed for generic consistency).
The model matrix (of the fixed effects), whose rows represent observations and whose columns represent explanatory variables corresponding to each fixed effect.
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"
#>