q, to be equal to
the number of measurement waves, T. Random effects
are grouped by subject and all q parameters receive
the DP prior. An additional set of random effects are
included that utilize a different grouping factor; e.g.
treatment(s) exposure or dosage. These additional random
effects are mapped back to subjects through a multiple
membership weight matrix.dpgrowmm(y, subject, trt, time, n.random, n.fix_degree, formula, random.only,
data, Omega, group, subj.aff, W.subj.aff, multi, n.iter, n.burn, n.thin,
strength.mm, shape.dp, rate.dp, plot.out, option)N captures
the number of subject-time cases (repeated subject
measures). Data may reflect unequal number of measures
per subject. Missing o(1,1,1,2,2,3,3,3,..N (number of cases) indicating treatment
group assignments for each case. May also be input as
length P vector, where P is the number of
unique subjects, iN,
capturing the time points associated to each by-subject
measure. Mav leave blank if only one time point (no
repeated measures).q. Since a DP prior
is used on subject effects, may be set equal to the
number of measurement waves, T. The y, trt,
time vectors will toge(time, ...,
time^(n.fix_degree), trt_1,time*trt_1, ...
,time^(n.fix_degree)*trt_l, trt_L,...,
time^(nformula with the following format,
y ~ x_1 + x_2*x_3 | z_1*z_2 as an object of class
formula. The bar, |, separates fixed and
random effecformula is entered without a |,
random.only defaultsdata.frame containing the variables
with names as specified in formula, including the
response, y.S is the number
of effects mapped to subjects through the multiple
membership construction. S, providing group identifiers for each of
S multiple membership effects (e.g.
(1,1,1,2,2,...). If excluded, it is assumed there
is a single group.subject composed with unique subject identifiers
that are linked to the multiple membership effects; e.g.
one or more treatment cohorts. If all subjects are to
receive the mapping of multipleP.aff is the length of the unique subjects to whom
the multiple membership random effects applies. It is
assumed that the row ordeTRUE indicates the each of the S MM effects
is multivariate. Leave blank if univariate multiple
membership effects are desired. It is assumed that the
associated design matrixdpgrow will return (n.iter - n.burn)
posterior samples.tau_{gamma} ~ G(strength.mm,strength.mm)
prior on the precision parameter of either a CAR
(gamma ~ CAR(tau_gamma)) or independent
(gamma ~ N(0,tau^(-1)I_S) prior on thn is the
total number of subjects.TRUE.mmcar places a CAR prior on the set of multiple
membership effects; 2. mmi places the usual
independent Gaussian priors on the set of multiple
membership effects. 3. dpgrowmm object, for which many methods are
available to return and view results. Generic functions
applied to an object, res of class dpgrow,
includes:call, the
function call made to dpgrowmm and
summary.results, which contains a list of objects
that include 95% credible intervals for each set of
sampled parameters, specified as (2.5%, mean,
97.5%, including fixed and random effects. Also
contains model fit statistics, including DIC (and
associated Dbar, Dhat, pD, pV),
as well as the log pseudo marginal likelihood (LPML), a
leave-one-out fit statistic. Note that DIC is
constructed as DIC3 (see Celeaux et. al. 2006),
where the conditional likehihood evaluated at the posterior
mode is replaced by the marginal predictive density.
Lastly, the random and fixed effects design matrices,
X, Z, are returned that include both the user input
nuisance covariates appended to the time and
treatment-based covariates constructed by dpgrowmm.n.iter -
n.burn) posterior sampling iterations for every model
parameter, including fixed and random effects.dpgrow, dpgrowmult## extract simulated dataset
library(growcurves)
data(datsim)
## attach(datsim)
## Model with DP on clients effects, but now INCLUDE session random effects
## in a multiple membership construction communicated with the N x S matrix, W.subj.aff.
## Returns object, res.mm, of class "dpgrowmm".
shape.dp = 3
strength.mm = 0.001
res.mm = dpgrowmm(y = datsim$y, subject = datsim$subject,
trt = datsim$trt, time = datsim$time,
n.random = datsim$n.random,
n.fix_degree = 2, Omega = datsim$Omega,
group = datsim$group,
subj.aff = datsim$subj.aff,
W.subj.aff = datsim$W.subj.aff,
n.iter = 10000, n.burn = 2000, n.thin = 10,
shape.dp = shape.dp, rate.dp = rate.dp,
strength.mm = strength.mm, option = "mmcar")
plot.results = plot(res.mm) ## ggplot2 plot objects,
summary.results = summary(res.mm) ## credible intervals and fit statistics
samples.posterior = samples(res.mm) ## posterior sampled valuesRun the code above in your browser using DataLab