ancova {rbmi} | R Documentation |
Analysis of Covariance
Description
Performs an analysis of covariance between two groups returning the estimated "treatment effect" (i.e. the contrast between the two treatment groups) and the least square means estimates in each group.
Usage
ancova(data, vars, visits = NULL, weights = c("proportional", "equal"))
Arguments
data |
A |
vars |
A |
visits |
An optional character vector specifying which visits to
fit the ancova model at. If |
weights |
Character, either |
Details
The function works as follows:
Select the first value from
visits
.Subset the data to only the observations that occurred on this visit.
Fit a linear model as
vars$outcome ~ vars$group + vars$covariates
.Extract the "treatment effect" & least square means for each treatment group.
Repeat points 2-3 for all other values in
visits
.
If no value for visits
is provided then it will be set to
unique(data[[vars$visit]])
.
In order to meet the formatting standards set by analyse()
the results will be collapsed
into a single list suffixed by the visit name, e.g.:
list( trt_visit_1 = list(est = ...), lsm_ref_visit_1 = list(est = ...), lsm_alt_visit_1 = list(est = ...), trt_visit_2 = list(est = ...), lsm_ref_visit_2 = list(est = ...), lsm_alt_visit_2 = list(est = ...), ... )
Please note that "ref" refers to the first factor level of vars$group
which does not necessarily
coincide with the control arm. Analogously, "alt" refers to the second factor level of vars$group
.
"trt" refers to the model contrast translating the mean difference between the second level and first level.
If you want to include interaction terms in your model this can be done
by providing them to the covariates
argument of set_vars()
e.g. set_vars(covariates = c("sex*age"))
.
Weighting
"proportional"
is the default scheme that is used. This is equivalent to standardization,
i.e. the lsmeans in
each group are equal to the predicted mean outcome from the ancova model for
that group based on baseline characteristics of all subjects regardless of
their assigned group. The alternative weighting scheme, "equal"
, creates hypothetical
patients by expanding out all combinations of the models categorical covariates. The
lsmeans are then calculated as the average of
the predicted mean outcome for these hypothetical patients assuming they come from each
group in turn.
In short:
-
"proportional"
weights categorical covariates based upon their frequency of occurrence in the data. -
"equal"
weights categorical covariates equally across all theoretical combinations.