Plot Actual and Predicted Response Variable Means by Study Arm and Subgroup.
Source:R/extras.R
ncs_plot_means_subgroup.RdThis function accepts a data set, probably produced by
ncs_analysis_subgroup(), and it uses ggplot2 to
produce a grid of plots, one for each combination of
study arm and subgroup. The time variable is along the x-axis, and the
response variable is along the y-axis. The actual means of the response
variable are points plotted in one color, and the
modeled means are plotted in another color. Each point also has its
confidence interval plotted.
Usage
ncs_plot_means_subgroup(
data,
arm = "arm",
time = "time",
subgroup = "subgroup",
est = "est",
lower = "lower",
upper = "upper",
model_est = "response_est",
model_lower = "response_lower",
model_upper = "response_upper"
)Arguments
- data
(
data frame)
a data frame, probably produced byncs_analysis(), containing the actual and predicted means. Each row should have a unique combination ofarm,time, andsubgroup.- arm
(
string)
the name of the study arm variable indata. There will be a separate column of plots produced for each study arm.- time
(
string)
the name of the time or visit variable indata. These values correspond to the x-axis.- subgroup
(
string)
the name of the subgroup variable indata. There will be a separate row of plots produced for each subgroup.- est, lower, upper
(
string)
the name of the variables indatacontaining the actual response variable's mean and confidence interval bounds. These values correspond to the y-axis.- model_est, model_lower, model_upper
(
string)
the name of the variables indatacontaining the predicted response variable's mean and confidence interval bounds. These values correspond to the y-axis.
Value
An object returned by ggplot2::ggplot().
Examples
if (FALSE) { # interactive()
# Create a usable data set out of mmrm::fev_data
fev_mod <- mmrm::fev_data
fev_mod$VISITN <- fev_mod$VISITN * 10
fev_mod$time_cont <- fev_mod$VISITN + rnorm(nrow(fev_mod))
fev_mod$obs_visit_index <- round(fev_mod$time_cont)
# Analysis result data set
ncs_data_results_subgroup <-
ncs_analysis_subgroup(
data = fev_mod,
response = FEV1,
subject = USUBJID,
arm = ARMCD,
control_group = "PBO",
subgroup = RACE,
subgroup_comparator = "Asian",
time_observed_continuous = time_cont,
df = 2,
time_observed_index = obs_visit_index,
time_scheduled_continuous = VISITN,
time_scheduled_baseline = 10,
time_scheduled_label = AVISIT,
covariates = ~ FEV1_BL + RACE,
cov_structs = c("ar1", "us")
)
ncs_plot_means_subgroup(ncs_data_results_subgroup$between)
}