model.matrix.tramME | R Documentation |
tramME
modelsModel matrix for fixed effects, random effects, and baseline transformations (with interacting terms if present).
## S3 method for class 'tramME'
model.matrix(
object,
data = model.frame(object),
type = c("Y", "X", "Zt"),
drop_unused_groups = FALSE,
keep_sign = TRUE,
simplify = FALSE,
...
)
object |
A |
data |
A |
type |
"X": Fixed effects model matrix. "Zt": Random effects model matrix (transposed). "Y": Model matrices for the baseline transfromations. |
drop_unused_groups |
Logical; remove unused levels of the random effects.
(see |
keep_sign |
Logical; the terms will have the same sign as in the
|
simplify |
Logical; Remove empty |
... |
Optional arguments. |
Creates model matrices for fixed effects (type = "X"
) and random
effects (type = "Zt"
) and baseline transfromation (type = "Y"
),
by evaluating the respective basis functions given a new dataset.
The response values may be exact, censored (left, right, interval) and truncated (left, right, interval), and the function returns several, potentially empty, model matrices:
Ye: Exact observations.
Yeprime: The model matrix corresponding to the first derivative of the baseline transformation, evaluated at exact observations.
Yl: Left-censored observations.
Yr: Rigt-censored observations.
Yil and Yir: Interval-censored observations evaluated at the left and right bounds of the interval.
Ytl: Left-truncated observations.
Ytr: Rigt-truncated observations.
Ytil and Ytir: Interval-truncated observations evaluated at the left and right bounds of the interval.
for the baseline transfromations (unless simplify = TRUE
).
List of requested model matrices.
The model matrix of the random effects is a sparse matrix and it is transposed
to be directly used with Matrix::crossprod
which is faster than transposing
and multiplying ("Zt" instead of "Z").
library("survival")
rats$litter <- factor(rats$litter)
m <- CoxphME(Surv(time, status) ~ rx + (1 | litter), data = rats,
log_first = TRUE, nofit = TRUE)
mm <- model.matrix(m)
nd <- model.frame(m)[rep(1, 100), ]
nd[[1]] <- seq(1, 120, length.out = 100)
mm2 <- model.matrix(m, data = nd, simplify = TRUE)
mm3 <- model.matrix(m, data = nd, simplify = TRUE, drop_unused_groups = TRUE)
## compare mm2$Zt & mm3$Zt
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.