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.
dpgrow(y, subject, trt, time, n.random, n.fix_degree, formula, random.only, data, n.iter, n.burn, n.thin, 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 occasions are left out as no
NA values are allowed.(1,1,1,2,2,3,3,3,...,n,n,n), where n is the total
number of subjects.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, indicating subject group assignment.
Multiple treatment groups are allowed and if the vector is entered as numeric,
e.g. (0,1,2,3,..), the lowest numbered
group 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) groups,
then this input may be excluded (set to NULL).N, capturing the time
points associated to each by-subject
measure. Mav leave blank if only one time point (no repeated measures).q.
Under option = "dp" 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.(time, ..., time^(n.fix_degree), trt_1,time*trt_1, ... ,
time^(n.fix_degree)*trt_l, trt_L,..., time^(n.fix_degree)*trt_L).
If is.null(n.fix_degree) | n.fix_degree == 0 & is.null(trt)
time-by-treatment fixed effects and growth curves are not generated.formula 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 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 values 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, n.fix_degree
blank and entering only formula, instead. The model output plots, will, however
exclude growth curves in that event. If a formula is input
(which requires response, y) then
the separate entry of y may be omitted. If the parameter y is input,
it will be over-written by that from formula.formula is entered without
a |, random.only defaults to FALSE.data.frame containing the variables with names as
specified in formula, including the response, y.dpgrow will
return (n.iter - n.burn) posterior samples.n is the total number of subjects.TRUE.dp places a DP prior on
the set of subject random effects;
2. lgm places the usual independent Gaussian priors on the set of random effects.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: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.
dpgrowmm
## Not run:
# ## extract simulated dataset
# library(growcurves)
# data(datsim)
# ## attach(datsim)
# ## run dpgrow mixed effects model; returns object of class "dpgrow"
# shape.dp = 4
# res = dpgrow(y = datsim$y, subject = datsim$subject,
# trt = datsim$trt, time = datsim$time,
# n.random = datsim$n.random,
# n.fix_degree = 2, n.iter = 10000,
# n.burn = 2000, n.thin = 10,
# shape.dp = shape.dp, option = "dp")
# 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