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

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

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

Arguments

object

A fitted model object from ssn_lm() or ssn_glm().

...

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

# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
mf04p <- ssn_import(temp_path, overwrite = TRUE)

ssn_mod <- ssn_lm(
  formula = Summer_mn ~ ELEV_DEM,
  ssn.object = mf04p,
  tailup_type = "exponential",
  additive = "afvArea"
)
model.matrix(ssn_mod)
#>    (Intercept) ELEV_DEM
#> 1            1     1947
#> 2            1     1952
#> 3            1     1958
#> 4            1     1923
#> 5            1     1932
#> 6            1     1940
#> 7            1     1940
#> 8            1     1945
#> 9            1     1948
#> 10           1     1950
#> 11           1     1949
#> 12           1     1950
#> 13           1     1951
#> 14           1     1977
#> 15           1     1984
#> 16           1     1993
#> 17           1     2007
#> 18           1     2009
#> 19           1     2012
#> 20           1     2023
#> 21           1     2023
#> 22           1     2026
#> 23           1     1988
#> 24           1     2013
#> 25           1     2015
#> 26           1     2015
#> 27           1     2038
#> 28           1     2052
#> 29           1     2066
#> 30           1     2085
#> 31           1     1975
#> 32           1     1982
#> 33           1     1999
#> 34           1     2002
#> 35           1     1997
#> 36           1     2006
#> 37           1     2026
#> 38           1     2036
#> 39           1     2046
#> 40           1     2050
#> 41           1     2071
#> 42           1     2077
#> 43           1     2016
#> 44           1     2034
#> 45           1     2042
#> attr(,"assign")
#> [1] 0 1