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.
rbmi_ancova(
data,
vars,
visits = NULL,
weights = c("counterfactual", "equal", "proportional_em", "proportional")
)a list of variance (var_*), treatment effect (trt_*), and
least square mean (lsm_*) estimates for each visit, organized as
described in Details above.
A data.frame containing the data to be used in the model.
A vars object as generated by the set_vars() function from the rbmi package. Only the group,
visit, outcome and covariates elements are required. See details.
An optional character vector specifying which visits to
fit the ancova model at. If NULL, a separate ancova model will be fit to the
outcomes for each visit (as determined by unique(data[[vars$visit]])).
See details.
Character, either "counterfactual" (default), "equal",
"proportional_em" or "proportional".
Specifies the weighting strategy to be used when calculating the lsmeans.
See the weighting section for more 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 rbmi_analyse() the results will be collapsed
into a single list suffixed by the visit name, e.g.:
list(
var_visit_1 = list(est = ...),
trt_B_visit_1 = list(est = ...),
lsm_A_visit_1 = list(est = ...),
lsm_B_visit_1 = list(est = ...),
var_visit_2 = list(est = ...),
trt_B_visit_2 = list(est = ...),
lsm_A_visit_2 = list(est = ...),
lsm_B_visit_2 = list(est = ...),
...
)
Please note that "trt" refers to the treatment effects, and "lsm" refers to the least
square mean results. In the above example vars$group has two factor levels A and B.
The new "var" refers to the model estimated variance of the residuals.
If you want to include interaction terms in your model this can be done
by providing them to the covariates argument of the set_vars() function from the rbmi package
e.g. set_vars(covariates = c("sex*age")).