Description Usage Arguments Details Value Author(s) References See Also Examples
model.matrix
creates a design (or model) matrix, e.g., by expanding factors to a set of dummy variables (depending on the contrasts) and expanding interactions similarly.
1 2 | ## S3 method for class 'jmdem'
model.matrix(object, submodel = c("both", "mean", "dispersion"), ...)
|
object |
the function family accesses the family objects which are stored within objects created by |
submodel |
character. The family of the specified submodel. For |
... |
further arguments passed to or from other methods. |
model.matrix
creates a design matrix from the description given in terms(object)
, using the data in data
which must supply variables with the same names as would be created by a call to model.frame(object)
or, more precisely, by evaluating attr(terms(object), "variables")
.
The design matrix for a regression-like model with the specified formula and data.
There is an attribute "assign
", an integer vector with an entry for each column in the matrix giving the term in the formula which gave rise to the column. Value 0
corresponds to the intercept (if any), and positive values to terms in the order given by the term.labels
attribute of the terms
structure corresponding to object.
If there are any factors in terms in the model, there is an attribute "contrasts
", a named list with an entry for each factor. This specifies the contrasts that would be used in terms in which the factor is coded by contrasts (in some terms dummy coding may be used), either as a character vector naming a function or as a numeric matrix.
Karl Wu Ka Yui (karlwuky@suss.edu.sg)
Chambers, J. M. (1992). Data for models. Chapter 3 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
model.frame
, model.extract
, terms
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Example in jmdem(...)
MyData <- simdata.jmdem.sim(mformula = y ~ x, dformula = ~ z,
mfamily = poisson(),
dfamily = Gamma(link = "log"),
beta.true = c(0.5, 4),
lambda.true = c(2.5, 3), n = 100)
fit <- jmdem(mformula = y ~ x, dformula = ~ z, data = MyData,
mfamily = poisson, dfamily = Gamma(link = "log"),
dev.type = "deviance", method = "CG")
## Extract the design matrix of the mean submodel
model.matrix(fit, submodel = "mean")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.