Title: | Joint Marginal-Conditional Model |
---|---|
Description: | Fits joint marginal conditional models for multivariate longitudinal data, as in Proudfoot, Faig, Natarajan, and Xu (2018) <doi:10.1002/sim.7552>. Development of this package was supported by the UCSD Altman Translational Research Institute, NIH grant UL1TR001442. The content is solely the responsibility of the authors and does not necessarily represent the official views of the NIH. |
Authors: | James Proudfoot |
Maintainer: | James Proudfoot <[email protected]> |
License: | GPL-2 |
Version: | 1.0.0 |
Built: | 2024-12-05 07:09:37 UTC |
Source: | CRAN |
Produces an object of class "MargCond"
which is a marginal-conditional multivariate model.
MargCond(formula, data, ID, tol = 1e-04, max.iter = 50, corstr = "independence", silent = F)
MargCond(formula, data, ID, tol = 1e-04, max.iter = 50, corstr = "independence", silent = F)
formula |
a two-sided linear formula object similar to those in |
data |
a data frame in which to interpret the variables occuring in the |
ID |
a vector which identifies the clusters. The length of |
tol |
the tolerance used in the fitting algorithm. |
max.iter |
the maximum number of iterations for the ES algorithm. |
corstr |
a character string specifying the correlation structure.
The following are permitted:
|
silent |
a logical variable controlling whether an indication at each iteration is printed. |
The joint marginal-conditional model
Care should be taken when specifying the random effects structure (see the singular models section of https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html). As initial estimates for the expectation-substitution algorithm are taken from the univariate mixed model fits, we recommend that these models be fit separately first and examined to ensure that they are not over parameterized.
An object of class "MargCond"
representing the fit.
An object of class "MargCond"
is a list containing the following components:
coefficients |
a named vector of coefficients. |
sigma |
a named vector of outcome error standard deviations. |
SE |
a vector of coefficient, random effect, and error standard deviations. |
residuals |
the residuals, that is response minus fitted values. |
working.correlation |
the working correlation returned by the GEE step at convergence. |
rand.eff |
the random effect covariance matrix. |
outcomes |
vector of outcome names |
Call |
the matched call. |
v.cov |
the scaled covariance matrix of theta |
obs |
the total number of observations |
groups |
the total number of clusters |
converge |
logical indicator of whether the expectation-substitution algorithm converged (i.e. the difference between each element of theta from the previous iteration is smaller than |
Proudfoot J. A., Faig W., Natarajan L., and Xu R. (2018) A joint marginal-conditional model for multivariate longitudinal data. Statistics in Medicine. https://doi.org/10.1002/sim.7552
set.seed(2112) NN = 80 n_times = 1:3 ## Simulating some data simdat <- simDat(n = NN, fixed_effects = list(c(1, 1, 2), c(1.5, 1, 3)), rand_effects = list(1, 1), error_var = c(4, 4), error_structure = 'normal', rho = .35, times = n_times, X = cbind(rep(1, NN * length(n_times)), rnorm(NN * length(n_times), 0, 2), rbinom(NN * length(n_times), 1, .5)), Z = cbind(rep(1, NN * length(n_times)))) ## Adding random missing values aa <- sample(1:nrow(simdat), 10, replace = TRUE) bb <- sample(1:7, 10, replace = TRUE) for (i in 1:length(aa)) { simdat[aa[i], bb[i]] <- NA } ## A fit for this simulated multivariate longitudinal data, ## including a random intercept and exchangeable correlation ## structure. summary(MargCond(c(outcome1, outcome2) ~ X2 + X3 + (1 | ID), data = simdat, ID = simdat$ID, corstr = "exchangeable"))
set.seed(2112) NN = 80 n_times = 1:3 ## Simulating some data simdat <- simDat(n = NN, fixed_effects = list(c(1, 1, 2), c(1.5, 1, 3)), rand_effects = list(1, 1), error_var = c(4, 4), error_structure = 'normal', rho = .35, times = n_times, X = cbind(rep(1, NN * length(n_times)), rnorm(NN * length(n_times), 0, 2), rbinom(NN * length(n_times), 1, .5)), Z = cbind(rep(1, NN * length(n_times)))) ## Adding random missing values aa <- sample(1:nrow(simdat), 10, replace = TRUE) bb <- sample(1:7, 10, replace = TRUE) for (i in 1:length(aa)) { simdat[aa[i], bb[i]] <- NA } ## A fit for this simulated multivariate longitudinal data, ## including a random intercept and exchangeable correlation ## structure. summary(MargCond(c(outcome1, outcome2) ~ X2 + X3 + (1 | ID), data = simdat, ID = simdat$ID, corstr = "exchangeable"))
A function that simulates correlated multivariate data based on a set of fixed and random effects.
simDat(n, fixed_effects, rand_effects, error_var = c(2, 2), error_structure = "normal", rho = 0, times = 1:5, X = NULL, Z = NULL)
simDat(n, fixed_effects, rand_effects, error_var = c(2, 2), error_structure = "normal", rho = 0, times = 1:5, X = NULL, Z = NULL)
n |
total sample size (number of clusters) |
fixed_effects |
list of fixed effect vectors for each outcome |
rand_effects |
list of random effect vectors for each outcome |
error_var |
vector of error variances for each outcome |
error_structure |
structure for the random error term, either |
rho |
correlation between outcomes |
times |
times for each repeated measure |
X |
fixed effect design matrix |
Z |
random effect design matrix |
A dataframe included simulated outcomes and the design matrices
set.seed(2112) NN = 80 n_times = 1:3 ## Simulating some data simdat <- simDat(n = NN, fixed_effects = list(c(1, 1, 2), c(1.5, 1, 3)), rand_effects = list(1, 1), error_var = c(4, 4), error_structure = 'normal', rho = .35, times = n_times, X = cbind(rep(1, NN * length(n_times)), rnorm(NN * length(n_times), 0, 2), rbinom(NN * length(n_times), 1, .5)), Z = cbind(rep(1, NN * length(n_times)))) ## Adding random missing values aa <- sample(1:nrow(simdat), 10, replace = TRUE) bb <- sample(1:7, 10, replace = TRUE) for (i in 1:length(aa)) { simdat[aa[i], bb[i]] <- NA }
set.seed(2112) NN = 80 n_times = 1:3 ## Simulating some data simdat <- simDat(n = NN, fixed_effects = list(c(1, 1, 2), c(1.5, 1, 3)), rand_effects = list(1, 1), error_var = c(4, 4), error_structure = 'normal', rho = .35, times = n_times, X = cbind(rep(1, NN * length(n_times)), rnorm(NN * length(n_times), 0, 2), rbinom(NN * length(n_times), 1, .5)), Z = cbind(rep(1, NN * length(n_times)))) ## Adding random missing values aa <- sample(1:nrow(simdat), 10, replace = TRUE) bb <- sample(1:7, 10, replace = TRUE) for (i in 1:length(aa)) { simdat[aa[i], bb[i]] <- NA }