Learn R Programming

growcurves (version 0.2.4.1)

ddpgrow: Bayesian semiparametric growth curve models.

Description

Employs an anova Dependent Dirichlet Process (DDP) prior on the set of by-subject random effect parameters with dependence indexed by multiple membership effects under repeated waves of measurements to allow the number of random effect parameters specified per subject, 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. The resulting joint marginal distribution over the data is a DP mixture.

Usage

ddpgrow(y, subject, trt, time, n.random, n.fix_degree, formula, random.only, data, dosemat, numdose, typetreat, labt, Omega, n.iter, n.burn, n.thin, shape.dp, rate.dp, M.init, plot.out)

Arguments

y
A univariate continuous response, specified as an N x 1 matrix or vector, where N captures the number of subject-time cases (repeated subject measures). Data may reflect unequal number of measures per subject. Missing occasions are left out as no NA values are allowed.
subject
The objects on which repeated measures are conducted that serves as the random effects grouping factor. Input as an N x 1 matrix or vector of subject-measure cases in either integer or character formt; e.g. (1,1,1,2,2,3,3,3,...,n,n,n), where n is the total number of subjects.
trt
An integer or character matrix/vector of length N (number of cases) indicating treatment arm assignments for each case. May also be input as length n vector, where n is the number of unique subjects, indicating subject arm assignment. Multiple treatment arms are allowed and if the vector is entered as numeric, e.g. (0,1,2,3,..), the lowest numbered arm is taken as baseline (captured by global fixed effects). If entered in character format, the first treatment entry is taken as baseline. If the are no treatment (vs. control) arm, then this vector is composed of a single value for all entries.
time
A univariate vector of length N, capturing the time points associated to each by-subject measure.
n.random
The desired number of subject random effect terms, q. May be set equal to the number of measurement waves, T. The y, trt, time vectors will together be used to create both fixed and random effect design matrices. The random effects matrix will be of the the form, (1, time, ... , time^(n.random - 1)) (grouped, by subject). This formulation is a growth curve model that allows assessment of by-treatment effects and by-client growth curves.
n.fix_degree
The desired polynomial order in time to use for generating time-based fix effects. The fixed effects matrix will be constructed as, (time, ..., time^(n.fix_degree), trt_1,time*trt_1, ... ,time^(n.fix_degree)*trt_l, trt_L,..., time^(n.fix_degree)*trt_L).
formula
Nuisance fixed and random effects may be entered in formula with the following format, y ~ x_1 + x_2*x_3 | z_1*z_2 . The bar, |, separates fixed and random effects. If it is only desired to enter either fixed or random effects, but not both then the | may be omitted. Note: the nuisance random effects are assumed to be grouped by subject. The fixed and random effects valules may change with each repeated measure; however, within subject growth curves will keep constant z and x values between measurement waves. It is possible to bypass the growth curve construction by leaving y, trt, time, n.random blank and entering only formula, instead. The model output plots, will, however exclude growth curves in that event. If a formula is input and a response, y, is included, then the parameter input y may be omitted. If the y input is included, it will be over-written by that from formula.
random.only
A Boolean variable indicating whether the input formula contains random (for fixed) effects in the case that only one set are entered. If excluded and formula is entered without a |, random.only defaults to FALSE.
data
A data.frame containing the variables named in formula.
dosemat
An n x (sum(numdose)+1) matrix object that maps subjects to treatment dosages. The first column should be an intercept column (filled with 1's). If there is only a single treatment arm, then the number of columns in dosemat should be sum(numdose). There is always a leave-one-out dosage for dosemat. For multiple treatment arms, the null (0) treatment is the one left out.
numdose
A vector object containing the number of dosages for each treatment. So the length should be the same as typetreat.
typetreat
A vector object specifying the prior formulation for each treatment. The choices for prior formulations are c("car","mvn","ind").
labt
An optional vector object (of the same length as typetreat) providing user names for each treatment. The names are used in plot objects. If NULL, then the numerical order of treatment entries are used.
Omega
A list object of length equal to the number of treatments chosen with the "car" %in% typetreat. List element m contains an numdose[m] x numdose[m] numeric matrix to encode the CAR adjacency matrix, where numdose[m] is the number of dosages receiving the multivariate CAR prior. This input is required only under "car" %in% typetreat.
n.iter
Total number of MCMC iterations.
n.burn
Number of MCMC iterations to discard. ddpgrow will return (n.iter - n.burn) posterior samples.
n.thin
Gap between successive sampling iterations to save.
shape.dp
Shape parameter under a c ~ G(shape.dp, rate.dp) prior on the concentration parameter of the DP (prior on the set of random effects parameters, b_1, ..., b_n ~ DP(c,G_0) where n is the total number of subjects.
rate.dp
Rate parameter under a c ~ G(shape.dp, rate.dp) prior on the concentration parameter of the DP.
M.init
Scalar value capturing number of initial subject clusters to kick-off MCMC chain.
plot.out
A boolean variable indicating whether user wants to return plots with output results. Defaults to TRUE.

Value

S3 dpgrow object, for which many methods are available to return and view results. Generic functions applied to an object, res of class dpgrow, includes: , includes:

References

T. D. Savitsky and S. M. Paddock (2011) Bayesian Hierarchical Semiparametric Modeling of Longitudinal Post-treatment Outcomes from Open-enrollment Therapy Groups, submitted to: JRSS Series A (Statistics in Society).

T. D. Savitsky and S. M. Paddock (2011) Visual Sufficient Statistics for Repeated Measures data with growcurves for R, submitted to: Journal of Statistical Software.

See Also

dpgrowmult, dpgrowmm, dpgrow

Examples

Run this code
## Not run: 
# ## extract simulated dataset
# library(growcurves)
# data(datddpsim)
# ## attach(datddpsim)
# ## run dpgrow mixed effects model; returns object of class "ddpgrow"
# shape.dp	= 4
# res		= ddpgrow(y = dat$y, subject = dat$subject, 
# 		trt = dat$trt, time = dat$time,
# 		typetreat = c("mvn","car","ind","car"), 
# 		numdose = dat$numdose, 
# 		labt = dat$labt, dosemat = dat$dosemat, 
# 		Omega = dat$Omega, n.random = dat$n.random, 
# 		n.fix_degree = 2, n.iter = 10000, n.burn = 2000, 
# 		n.thin = 10, shape.dp = 1)
# plot.results	= plot(res) ## ggplot2 plot objects, including growth curves
# summary.results = summary(res) ## parameter credible intervals,  fit statistics
# samples.posterior = samples(res) ## posterior sampled values
# ## End(Not run)

Run the code above in your browser using DataLab