effects.lmm | R Documentation |
Estimate average counterfactual outcome or contrast of outcome based on a linear mixed model.
## S3 method for class 'lmm'
effects(
object,
variable,
effects = "identity",
type = "outcome",
repetition = NULL,
conditional = NULL,
ref.repetition = 1,
ref.variable = 1,
newdata = NULL,
rhs = NULL,
multivariate = FALSE,
prefix.time = NULL,
prefix.var = TRUE,
sep.var = ",",
...
)
object |
a |
variable |
[character/list] exposure variable relative to which the effect should be computed. Can also be a list with two elements: the first being the variable (i.e. a character) and the second the levels or values for this variable to be considered. |
effects |
[character] should the average counterfactual outcome for each variable level be evaluated ( |
type |
[character/numeric vector] Possible transformation of the outcome: no transformation ( |
repetition |
[character vector] repetition at which the effect should be assessed. By default it will be assessed at all repetitions. |
conditional |
[character/data.frame] variable(s) conditional to which the average conterfactual outcome or treatment effect should be computed. Alternatively can also be a data.frame where each column correspond to a variable and the rows to the level of the variable(s). |
ref.repetition |
[numeric or character] index or value of the reference level for the repetition variable.
Only relevant when |
ref.variable |
[numeric or character] index or value of the reference level for the exposure variable.
Only relevant when |
newdata |
[data.frame] a dataset reflecting the covariate distribution relative to which the average outcome or contrast should be computed. |
rhs |
[numeric] the right hand side of the hypothesis. |
multivariate |
[logical] should a multivariate Wald test be used to simultaneously test all null hypotheses. |
prefix.time |
[character] When naming the estimates, text to be pasted before the value of the repetition variable.
Only relevant when |
prefix.var |
[logical] When naming the estimates, should the variable name be added or only the value? |
sep.var |
[character] When naming the estimates, text to be pasted between the values to condition on.
Only relevant when |
... |
Arguments passed to |
The uncertainty is quantified assuming the contrast matrix to be a-priori known. Said otherwise the standard error does not account for the uncertainty about the covariate distribution.
#### simulate data in the long format ####
set.seed(10)
dL <- sampleRem(100, n.times = 3, format = "long")
#### Linear Mixed Model ####
eUN.lmm <- lmm(Y ~ visit + X1 + X2 + X5,
repetition = ~visit|id, structure = "UN", data = dL)
## outcome
e.YbyX1 <- effects(eUN.lmm, variable = "X1")
e.YbyX1
summary(e.YbyX1)
model.tables(e.YbyX1)
coef(e.YbyX1, type = "contrast")
effects(eUN.lmm, effects = "difference", variable = "X1")
effects(eUN.lmm, effects = "difference", variable = "X1", repetition = "3")
## change
effects(eUN.lmm, type = "change", variable = "X1")
effects(eUN.lmm, type = "change", variable = "X1", ref.repetition = 2)
effects(eUN.lmm, type = "change", variable = "X1", conditional = NULL)
effects(eUN.lmm, type = "change", effects = "difference", variable = "X1")
## auc
effects(eUN.lmm, type = "auc", variable = "X1")
effects(eUN.lmm, type = "auc", effects = "difference", variable = "X1")
#### fit Linear Mixed Model with interaction ####
dL$X1.factor <- as.factor(dL$X1)
dL$X2.factor <- as.factor(dL$X2)
eUN.lmmI <- lmm(Y ~ visit * X1.factor + X2.factor + X5,
repetition = ~visit|id, structure = "UN", data = dL)
## average counterfactual conditional to a categorical covariate
effects(eUN.lmmI, variable = "X1.factor",
conditional = "X2.factor", repetition = "3")
effects(eUN.lmmI, type = "change", variable = "X1.factor",
conditional = "X2.factor", repetition = "3")
effects(eUN.lmmI, type = "auc", variable = "X1.factor", conditional = "X2.factor")
## average difference in counterfactual conditional to a categorical covariate
effects(eUN.lmmI, effects = "difference", variable = "X1.factor",
conditional = c("X2.factor"), repetition = "3")
effects(eUN.lmmI, effects = "difference", type = "change", variable = "X1.factor",
conditional = c("X2.factor"), repetition = "3")
effects(eUN.lmmI, effects = "difference", type = "auc", variable = "X1.factor",
conditional = "X2.factor")
## average difference in counterfactual conditional to a covariate
effects(eUN.lmmI, effect = "difference", variable = "X1.factor",
conditional = data.frame(X5=0:2), repetition = "3")
effects(eUN.lmmI, effect = "difference", type = "change", variable = "X1.factor",
conditional = data.frame(X5=0:2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.