
Methods for object of class "MixMod"
for standard generic functions.
coef(object, …)# S3 method for MixMod
coef(object, …)
fixef(object, …)
# S3 method for MixMod
fixef(object, …)
ranef(object, …)
# S3 method for MixMod
ranef(object, post_vars = FALSE, …)
confint(object, parm, level = 0.95, …)
# S3 method for MixMod
confint(object,
parm = c("fixed-effects", "var-cov","extra"),
level = 0.95, …)
anova(object, …)
# S3 method for MixMod
anova(object, object2, test = TRUE, L = NULL, …)
fitted(object, …)
# S3 method for MixMod
fitted(object,
type = c("mean_subject", "subject_specific", "marginal"),
link_fun = NULL, …)
residuals(object, …)
# S3 method for MixMod
residuals(object,
type = c("mean_subject", "subject_specific", "marginal"),
link_fun = NULL, …)
objects inheriting from class "MixMod"
. When object2
is also provided, then the model behind object
must be nested within the model
behind object2
.
logical; if TRUE
the posterior variances of the random effects
are returned as an extra attribute of the numeric matrix produced by ranef()
.
character string; for which type of parameters to calculate confidence
intervals. Option "var-cov"
corresponds to the variance-covariance matrix of the
random effects. Option extra
corresponds to extra (shape/dispersion)
parameters in the distribution of the outcome (e.g., the
numeric scalar between 0 and 1 denoting the level of the confidence interval.
logical; should a p-value be calculated.
a numeric matrix representing a contrasts matrix. This is only used when in
anova()
only object
is provided, and it can only be specified for the fixed
effects. When L
is used, a Wald test is performed.
character string indicating the type of fitted values / residuals to calculate.
Option "mean_subject"
corresponds to only using the fixed-effects part; option
"subject_specific"
corresponds to using both the fixed- and random-effects
parts; option "marginal"
is based in multiplying the fixed effects design
matrix with the marginal coefficients obtained by marginal_coefs
.
the link_fun
of marginal_coefs
.
further arguments; currently none is used.
The estimated fixed and random effects, coefficients (this is similar as in package nlme), confidence intervals fitted values (on the scase on the response) and residuals.
# NOT RUN {
# simulate some data
set.seed(123L)
n <- 500
K <- 15
t.max <- 25
betas <- c(-2.13, -0.25, 0.24, -0.05)
D <- matrix(0, 2, 2)
D[1:2, 1:2] <- c(0.48, -0.08, -0.08, 0.18)
times <- c(replicate(n, c(0, sort(runif(K-1, 0, t.max)))))
group <- sample(rep(0:1, each = n/2))
DF <- data.frame(year = times, group = factor(rep(group, each = K)))
X <- model.matrix(~ group * year, data = DF)
Z <- model.matrix(~ year, data = DF)
b <- cbind(rnorm(n, sd = sqrt(D[1, 1])), rnorm(n, sd = sqrt(D[2, 2])))
id <- rep(1:n, each = K)
eta.y <- as.vector(X %*% betas + rowSums(Z * b[id, ]))
DF$y <- rbinom(n * K, 1, plogis(eta.y))
DF$id <- factor(id)
################################################
fm1 <- mixed_model(fixed = y ~ year + group, random = ~ year | id, data = DF,
family = binomial())
head(coef(fm1))
fixef(fm1)
head(ranef(fm1))
confint(fm1)
confint(fm1, "var-cov")
head(fitted(fm1, "subject_specific"))
head(residuals(fm1, "marginal"))
fm2 <- mixed_model(fixed = y ~ year * group, random = ~ year | id, data = DF,
family = binomial())
# likelihood ratio test between fm1 and fm2
anova(fm1, fm2)
# the same but with a Wald test
anova(fm2, L = rbind(c(0, 0, 0, 1)))
# }
Run the code above in your browser using DataLab