stem_generator: Generate disease stems

Description Usage Arguments Value Examples

View source: R/stem_generator.R

Description

Generate disease stems on the basis of combination frequency (if no outcome_positions is passed) or the proportion of records associated with an outcome event (if outcome_positions is passed).

Usage

1
2
3
4
5
6
7
8
9
stem_generator(
  poscolumn,
  max_combos = 3,
  all_diseases,
  outcome_positions = 0,
  min_freq = 0,
  tots,
  use_outcome = FALSE
)

Arguments

poscolumn

Vector of numbers which describe position of 1s in a comorbid string, generated using .get_locales().

max_combos

Number of maximum combinations to attempt.

all_diseases

List of positions associated with each disease, generated using .get_disease_counts().

outcome_positions

Numeric vector where each number refers to a record that suffered a particular outcome.

min_freq

Number between 0 and 1; minimum proportion of code combinations to be included in the stem. If outcome_column is passed, min_freq is the minimum event rate per combination to be considered.

tots

Total number of records included to allow calculation of disease frequency.

use_outcome

Logical if to use outcome variable for stem generation.

Value

A dataframe with the main_stem for each pattern up to a maximum set in max_combos.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
positions = list(c(1,2,3,4), c(3), c(3), c(2,3))
disease_counts = list(c(1), c(1,4), c(1,2,3,4), c(1))

# generate stems on basis of frequency
stem_generator(poscolumn = positions,
max_combos = 2,
all_diseases = disease_counts,
outcome_positions = 0, tots=4)

# generate stems on basis of outcome
stem_generator(poscolumn = positions,
 max_combos = 2,
 all_diseases = disease_counts,
 outcome_positions = c(2,3,4), tots = 4)

AJFOWLER/comorbidgroupr documentation built on May 11, 2021, 6:01 a.m.