index_fun: Calculate index based on classification scheme

index_funR Documentation

Calculate index based on classification scheme

Description

This is the third step of codify() %>% classify() %>% index(). The function takes classified case data and calculates (weighted) index sums as specified by weights from a classcodes object.

Usage

index(classified, ...)

## S3 method for class 'data.frame'
index(classified, ...)

## S3 method for class 'matrix'
index(classified, index = NULL, cc = NULL, ...)

Arguments

classified

output from classify()

...

used internally

index

name of column with 'weights' from corresponding classcodes object. Can be NULL if the index is just a unweighted count of all identified groups.

cc

classcodes object. Can be NULL if a classcodes object is already available as an attribute of classified (which is often the case) and/or if index = NULL.

Details

Index weights for subordinate hierarchical classes (as identified by attr(cc, "hierarchy")) are excluded in presence of superior classes if index specified with argument index.

Value

Named numeric index vector with names corresponding to rownames(classified)

See Also

Other verbs: categorize(), classify(), codify()

Examples


# Prepare some codified data with ICD-10 codes during 1 year (365 days)
# before surgery
x <-
  codify(
    ex_people,
    ex_icd10,
    id        = "name",
    code      = "icd10",
    date      = "surgery",
    days      = c(-365, 0),
    code_date = "admission"
  )

# Classify those patients by the Charlson comorbidity indices
cl <- classify(x, "charlson")

# Calculate (weighted) index values
head(index(cl))                  # Un-weighted sum/no of conditions for each patient
head(index(cl, "quan_original")) # Weighted index (Quan et al. 2005; see `?charlson`)
head(index(cl, "quan_updated"))  # Weighted index (Quan et al. 2011; see `?charlson`)

# Tabulate index for all patients.
# As expected, most patients are healthy and have index = 0/NA,
# where NA indicates no recorded hospital visits
# found in `ex_icd10` during codification.
# In practice, those patients might be assumed to have 0 comorbidity as well.
table(index(cl, "quan_original"), useNA = "always")

# If `cl` is a matrix without additional attributes (as imposed by `codify()`)
# an explicit classcodes object must be specified by the `cc` argument
cl2 <- as.matrix(cl)
head(index(cl2, cc = "charlson"))

eribul/coder documentation built on March 16, 2023, 12:50 a.m.