The function creates design (or model) matrices for BAMLSS, i.e., for each parameter of a bamlss.family object.

# S3 method for bamlss.frame
model.matrix(object, data = NULL, model = NULL,
  drop = TRUE, scale.x = FALSE, ...)

# S3 method for bamlss.formula
model.matrix(object, data = NULL, model = NULL,
  drop = TRUE, scale.x = FALSE, ...)

# S3 method for bamlss.terms
model.matrix(object, data = NULL, model = NULL,
  drop = TRUE, scale.x = FALSE, ...)

Arguments

object

A bamlss.frame, bamlss.formula or terms.bamlss object.

data

A data frame or list.

model

Character or integer, specifies the model for which design matrices should be returned.

drop

If model matrices for only one model are returned, the list structure is dropped.

scale.x

Logical, should the model matrices of the linear parts be scaled?

Not used.

Value

Depending on the type of model a named list of model matrices or a single model matrix.

See also

Examples

## Generate some data. d <- GAMart() ## Model formula. f <- list( num ~ x1 + x2 + id, sigma ~ x3 + fac + lon + lat ) ## Create a "bamlss.frame". bf <- bamlss.frame(f, data = d) ## Get the model matrices. X <- model.matrix(bf) head(X$sigma)
#> (Intercept) x3 facmedium fachigh lon lat #> 1 1 0.6025112 0 1 0.27272727 0.1818182 #> 2 1 0.2609428 1 0 0.22727273 0.3636364 #> 3 1 0.2150072 0 1 0.09090909 0.4090909 #> 4 1 0.4598864 0 0 0.04545455 0.8181818 #> 5 1 0.9621079 0 0 0.13636364 0.5000000 #> 6 1 0.8405208 1 0 0.90909091 0.6818182
## Same with "bamlss.formula". X <- model.matrix(bamlss.formula(f), data = d) head(X$sigma)
#> (Intercept) x3 facmedium fachigh lon lat #> 1 1 0.6025112 0 1 0.27272727 0.1818182 #> 2 1 0.2609428 1 0 0.22727273 0.3636364 #> 3 1 0.2150072 0 1 0.09090909 0.4090909 #> 4 1 0.4598864 0 0 0.04545455 0.8181818 #> 5 1 0.9621079 0 0 0.13636364 0.5000000 #> 6 1 0.8405208 1 0 0.90909091 0.6818182