
Posterior subgroup probabilities
Source:R/group_analysis_probability.R
group_analysis_probability.RdEstimate the posterior probability that each patient belongs to each level of each subgroup variable, given the patient-level survival data and the assumed subgroup statistics.
Arguments
- patient
Patient-level survival data, the output of
group_data_patient().- summary
Summary subgroup statistics, the output of
group_data_summary().
Value
A named list with one element per subgroup variable, in the
order the subgroup variables first appear in summary$variable.
Each element is a numeric matrix of the estimated posterior
probabilities \(p_{ik}\) of that subgroup variable:
Rows correspond to patients, in the same order as the rows of
patient.Columns correspond to the levels of the subgroup variable. The column names are exactly the levels, in the same order as in
summary.Each row sums to 1.
Details
group_analysis_probability() computes the estimated posterior
probabilities \(p_{ik}\) defined in the "Posterior probability
estimation" section of vignette("model", package = "retrogroup"),
separately for each subgroup variable. See that section for the
formulas, including the error when any probability is numerically
indistinguishable from zero.
The probabilities depend on the estimated prognostic effects
\(\hat{\gamma}_k\) and the estimated baseline cumulative hazard
\(\hat{\Lambda}_0(t)\) of
vignette("estimates", package = "retrogroup"). The prognostic
effects come from the event counts, the patient counts, and the
hazard ratios in summary, after clamping each event count to between
1/2 and \(n_k - 1/2\). The baseline cumulative hazard is a modified
Breslow estimate that uses the prognostic effects.
The total number of patients of every subgroup variable in
summary must equal the number of rows of patient, and the total
number of events of every subgroup variable must equal the number of
events in patient. See the details of group_data_summary() for how
to choose the counts.
See also
Other analysis:
group_analysis_summary()
Examples
patient <- group_data_patient(
group_example_patient(),
arm = "arm",
treatment = "Lev+5FU",
time = "time",
event = "event"
)
summary <- group_data_summary(
group_example_summary(),
variable = "variable",
level = "level",
patients = "patients",
events = "events",
hazard_ratio = "hazard_ratio"
)
probability <- group_analysis_probability(patient, summary)
names(probability)
#> [1] "age" "node4" "sex"
head(probability$age)
#> under 60 60 or over
#> [1,] 0.4751411 0.5248589
#> [2,] 0.4298317 0.5701683
#> [3,] 0.4187984 0.5812016
#> [4,] 0.4884546 0.5115454
#> [5,] 0.4106436 0.5893564
#> [6,] 0.4738574 0.5261426