aggregate_performance: Aggregate performance measures by cohort

Description Usage Arguments Details Value Methods (by generic) Examples

View source: R/aggregate_performance.R

Description

Aggregate performance measures by cohort

Usage

1
2
3
4
5
aggregate_performance(perf.estimates, reference = NULL,
  design.levels = LETTERS, fn.mods = NULL)

## S3 method for class 'mscagg'
print(x, ...)

Arguments

perf.estimates

A set of performance estimates of class mscraw, as computed by compute_performance

reference

The name of the reference score (default NULL, the first score is the reference). This will be the reference level of the scores in any later models.

design.levels

A character vector of alternate short names for the scores, to be used in naming the designs. Default is LETTERS, so that a possible design would be AB or ACD, instead of score1score2 or score1score3score4. The design variable is used in the definition of the random effects. See consistency.

fn.mods

A function used to summarize the moderators within cohorts. Moderators should be numeric as the mean is computed by default. Factor variables should converted to numeric prior to use in get_bs_samples. For example, if variable x2 has levels A, B, C and D, convert to x2f = 1 if x2 = A, B and 0, otherwise. If NULL, the default mean(x, na.rm = TRUE) is used.

x

An object of class mscagg, returned from aggregate_performance.

...

Other arguments to be passed to print.

Details

The aggregation of moderators here is different than what the function casemix is doing. casemix shows the actual levels of the moderators, either as median and IQR (or boxplots) for continuous variables, or tables (or barplots) for factor variables. In aggregate_performance we assume a single number is needed to describe the overall value of the moderator, which is most commonly the mean. Factor variables with two levels (e.g. A and B) should be converted to 0/1 variables. Unordered factor variables with more than 2 levels (e.g. A, B, C, and D) should be collapsed to 0/1 variables (for example 0 = A, B, 1 = C, D). Ordered factor variables (e.g. I, II, III, IV) should be converted to numeric variables (e.g. 1, 2, 3, 4). Any factor variables will be dropped in aggregate_performance.

Value

A list with the following elements, of class mscagg

cohorts

List of cohorts

yi

Differences in score performance

vi

Variance-covariance matrix for yi

contr

Score contrasts

design

"Design" of the study (that is, which scores could be calculated)

design.matrix

Design matrix, corresponding to contr

lbl

A label for the analysis, which shows up in plots and output datasets

fn

The function used to compute performance, for example calibration_slope

scores

A vector of the scores used

ref

The reference score

mods

A vector of names of the moderators

moderators

A dataframe containing aggregated moderators

Methods (by generic)

Examples

1
2
3
4
5
6
7
dat <- msc_sample_data()
bssamp <- get_bs_samples(dat, id, study, outcome, n.samples = 5, 
                  scores = c("a", "b", "c", "d", "e", "f"), 
                  moderators = c("age", "female", "x1", "sex"))
perf <- compute_performance(bssamp, fn = calibration_slope, lbl = "CS")
agg <- aggregate_performance(perf)
head(agg)

srhaile/mscpredmodel documentation built on Sept. 13, 2019, 3:44 p.m.