Parameters

The parameters.r file contains all the information necessary to execute the analyze_nis program. Download the file and read the comments to understand each variable.

#
# parameters.r
#
# Parameters / settings for NIS database analysis.
# Place this file in the desired folder for analysis.
# I like to use the outline (top right icon) to navigate this file.
#

#
# PARAMETERS -------------------------------------------------------------------
#

## Population -----

# Primary diagnosis or procedure, DX1/I10_DX1 or PR*/I10_PR* only.
#   - Separate multiple ICD codes by spaces, record matches ANY of the ICD codes.
#   - primary.dx.description: Optional description of the group, for figures.
#   - is.procedure: TRUE if these are procedure codes, or FALSE if these
#     are diagnosis codes.
#   - any.diagnosis: FALSE by default. TRUE if codes can be in ANY DX column.
primary.dx = "YOUR ICD CODES HERE"
primary.dx.description = "Admissions of patients with ________"
is.procedure = FALSE
any.diagnosis = FALSE

# Secondary diagnosis or procedure.
#   - Separate multiple ICD codes by spaces, record matches ANY of the ICD codes.
#   - Subpopulation only includes entries that match both the
#     primary diagnosis AND secondary diagnosis (if provided).
#   - secondary.dx.description: Optional description of the group, for figures.
secondary.dx = ""
secondary.dx.description = "Eligible"

# Subgroups can be used to stratify the analysis.
# Subgroups have both separate analysis as well as interaction p-value.
# Separate each value by spaces. Use groups defined above.
subgroups = ""

# Exclusion criteria. Write as a logical expression to filter out observations.
#   - Examples:
#     exclude minors and elderly: "AGE < 18 | AGE >= 65"
#     exclude men: "FEMALE == 0"
#     exclude elective admissions: "ELECTIVE == 1"
#     exclude races other than African American: "RACE != 2"
exclude = "AGE < 18"
exclude.group = NULL
# To limit what years to analyze, select the earliest year to use.
start.year = 2016

## Intervention/Comparisons -----

# Grouped variables from ICD-9 or ICD-10 codes, separated by spaces.
#   - Spaces are allowed in group names and appear in figures, but when
#     referencing these variables in matched.vars and predictors, refer
#     to them without spaces.
#   - You may also create a group beginning at a certain year, e.g. 2020+
groups = list(
  "COVID19" = "U071",
  # you can use spaces in the group names! make them easily understandable
  # when you use the group names elsewhere, you'll remove the spaces
)

# The primary predictor(s) i.e. the intervention(s) of the study.
# Separate each value by spaces.
# Should be binary variables. Can be groups, defined below.
interventions = "Intervention1 Intervention2 (each intervention name is continuous without spaces"

# The rest of the predictors to adjust for. Separate each value by spaces.
#   - You may also insert ELIXSUM or any elixhauser comorbidities.
#   - Categorical predictors should be prefixed with "i.", e.g. i.RACE.
predictors = paste(
  "YEAR AGE FEMALE RACE INSURED HOSP_LOCTEACH ZIPINC_QRTL AWEEKEND ELECTIVE HOSP_BEDSIZE HOSP_REGION ELIXSUM CHF CARDARRHYT VALVDISEASE PULMCIRC PVD HYPERTEN HYPERTENCOMP PARALYSIS OTHERNEURO CHRONPULM DIABUNCOMP DIABCOMP HYPOTHYROID LIVERDISEASE PEPTICULCER AIDSHIVXYZ LYMPHOMA METASTATIC SOLIDTUMOR RHEUMATOIDARTH COAGULOPATHY OBESITY WEIGHTLOSS FLUIDELECTRO BLOODLOSSANEMIA ANEMIADEF ALCOHOLABUSE DRUGABUSE PSYCHOSES DEPRESS RENALFAIL COVID19",
  # The #GROUPS# variable takes all the groups defined above and puts them here.
  # It intelligently omits any groups that you used for subgroups, interventions,
  # exclusion groups, or outcomes. To customize the predictors, you can easily remove
  # the #GROUPS# variable and simply write in the specific groups you want.
  "#GROUPS#"
)

### Propensity matching -----
# Propensity matching? Set to name of variable to match on, e.g. "URBANTEACH"
#     If you only have one intervention, this will be identical to it.
#     If you have more than one intervention, choose only one.
#     To skip propensity matching, set to empty quotes: ""
#     The propensity matching can be skipped per-outcome, defined in outcomes below.
# By default, we'll just copy over the interventions.
propensity = interventions

# Variables to match when propensity scoring. Separate each value by spaces.
#     Can include group names and DX or PR codes.
#     You may also insert ELIXSUM or any elixhauser comorbidities.
# By default, we'll just copy over all of the predictors here.
matched.vars = predictors

## Outcomes -----

# Outcomes. Must be predefined variables, or groups defined above.
# Whether the above outcome is a binary (TRUE) or continuous (FALSE) variable.
#     Remember that DIED is binary, whereas LOS and TOTCHGadj are continuous.
#     Custom outcomes you define will very likely be binary.
# Optionally:
#     specify unmatched = FALSE to disable unmatched analysis.
#     specify unmatched = FALSE to disable unmatched analysis.
#     specify family = PUT_FAMILY_HERE to change the GLM model.
outcomes = function(.) {
  .("DIED", is.binary = TRUE)
  .("LOS", is.binary = FALSE)
  .("TOTCHGadj", is.binary = FALSE)
}




## Extra configuration -----

# Add an "Other" column when there are more than one intervention
# i.e. everyone in the population not in the intervention groups
add.other = TRUE

### Custom processing -----
# Optional data processing. May include adding more columns or altering
# the database in some other way. If adding more columns, add them to the
# `keep` vector so that they will be included in the aggregate dataset.
# The variables 'dx', 'dxp', 'dxps', and 'exclude' will be present.
custom.processing = function(dt, year, keep) {

  ## For example:

  ## Add new column `Routine` for routine discharge dispositions:
  #dt <- dt %>% mutate(Routine = DISPUNIFORM == 'Routine')

  ## Log a progress update with the number of Routine admissions:
  #progress(year, "Routine", dt %>% filter(Routine == T) %>% count)

  ## Add the new `Routine` column to the `keep` vector.
  #keep <- c(keep, "Routine")

  return(list(dt=dt, keep=keep))
}

### Baseline characteristics -----
# Create baseline demographic and clinical characteristic tables, TRUE/FALSE.
create.characteristics.tables = TRUE
# Combine demographic and clinical characteristics into the same table, TRUE/FALSE.
combined.characteristics = FALSE
# If baseline characteristics have p < alpha, include those variables in
# propensity matching. To disable, set to 0.
match.characteristics.alpha = 0.05
# Validate propensity scores by generating new characteristic tables after
# propensity scoring, TRUE/FALSE.
validate.propensity = TRUE

# Create a correlation matrix of all clinical variables, TRUE/FALSE.
# If FALSE, you may still optionally create a correlation matrix at the end
# of analysis by typing in the console: create.correlation.matrix()
correlation.matrix = FALSE

### Stop before analysis -----
# Stop the script after saving the aggregate dataset but before analysis, TRUE/FALSE.
stop.before.analysis = FALSE

### Propensity settings -----
# Propensity matching method. Can be "nearest" for nearest neighbor matching
# (on the propensity score), "optimal" for optimal pair matching,
# "full" for optimal full matching, "genetic" for genetic matching,
# "cem" for coarsened exact matching, "exact" for exact matching,
# "cardinality" for cardinality and template matching, and "subclass"
# for subclassification.
propensity.method = "subclass"
# Propensity link function. Can be "logit" or "probit".
propensity.link = "logit"

### CPI settings -----
# Consumer Price Index (CPI).
# NOTE: The reference year you are conducting the analysis, NOT the database year!!
#   - Set to 1 for the reference year.
#   - Easiest solution: use an online CPI inflation calculator.
#   - Consider using the "hospital services" component of the CPI.
cpi = c(
  # year, cpi relative to now
  2016, 1.34,
  2017, 1.32,
  2018, 1.28,
  2019, 1.26,
  2020, 1.25,
  2021, 1.18,
  2022, 1.09
)

### File/CPU settings -----
# The folder name to save all the files. Default (NULL) is aggregate_TIME.
aggregate.dir = NULL

# Whether to manually select files, rather than a folder containing a dataset.
# If you want to use .fst files as input, this option must be enabled.
select.files = FALSE

# If selecting files individually, you may choose to split the processing
# of each file across multiple CPU cores. Set to 0 for as many as possible.
cores = 0

### Labels -----
demo.labels = list(
  YEAR = "Year",
  AGE = "Age, years",
  FEMALE = "Biological sex",
  RACE = "Race",
  INSURED = "Insurance status",
  PAY1 = "Insurance status",
  HOSP_LOCTEACH = "Hospital teaching status",
  HOSP_BEDSIZE = "Hospital bed size",
  HOSP_REGION = "Hospital region",
  AWEEKEND = "Weekend admission",
  ELECTIVE = "Elective admission",
  ZIPINC_QRTL = "Median household income in zip code"
)
clin.labels = list(
  DIED = "Mortality",
  LOS = "Length of stay",
  TOTCHGadj = "Total adjusted charges",
  ELIXSUM = "Elixhauser sum",
  AIDSHIVXYZ = "Acquired immune deficiency syndrome",
  CMR_AIDS = "Acquired immune deficiency syndrome",
  ALCOHOLABUSE = "Alcohol abuse",
  CMR_ALCOHOL = "Alcohol abuse",
  ANEMIA = "Deficiency anemias",
  ANEMIADEF = "Deficiency anemias",
  AUTOIMMUNE = "Autoimmune conditions",
  CMR_AUTOIMMUNE = "Autoimmune conditions",
  BLOODLOSSANEMIA = "Chronic blood loss anemias",
  CMR_BLDLOSS = "Chronic blood loss (iron deficiency)",
  CMR_CANCER_LEUK = "Leukemia",
  LYMPHOMA = "Lymphoma",
  CMR_CANCER_LYMPH = "Lymphoma",
  METASTATIC = "Metastatic cancer",
  CMR_CANCER_METS = "Metastatic cancer",
  SOLIDTUMOR = "Solid tumor without metastasis",
  CMR_CANCER_NSITU = "Solid tumor without metastasis, in situ",
  CMR_CANCER_SOLID = "Solid tumor without metastasis, malignant",
  CMR_CBVD = "Cerebrovascular disease",
  COAGULOPATHY = "Coagulopathy",
  CMR_COAG = "Coagulopathy",
  CMR_DEMENTIA = "Dementia",
  DEPRESS = "Depression",
  CMR_DEPRESS = "Depression",
  DIABCOMP = "Complicated diabetes",
  CMR_DIAB_CX = "Complicated diabetes",
  DIABUNCOMP = "Uncomplicated diabetes",
  CMR_DIAB_UNCX = "Uncomplicated diabetes",
  DRUGABUSE = "Drug abuse",
  CMR_DRUG_ABUSE = "Drug abuse",
  CMR_HF = "Heart failure",
  HYPERTENCOMP = "Complicated hypertension",
  CMR_HTN_CX = "Complicated hypertension",
  HYPERTEN = "Uncomplicated hypertension",
  CMR_HTN_UNCX = "Uncomplicated hypertension",
  LIVERDISEASE = "Liver disease",
  CMR_LIVER_MLD = "Liver disease, mild",
  CMR_LIVER_SEV = "Liver disease and failure, moderate to severe",
  CHRONPULM = "Chronic pulmonary disease",
  CMR_LUNG_CHRONIC = "Chronic pulmonary disease",
  CMR_NEURO_MOVT = "Neurological disorders affecting movement",
  OTHERNEURO = "Other neurological disorders",
  CMR_NEURO_OTH = "Other neurological disorders",
  CMR_NEURO_SEIZ = "Seizures and epilepsy",
  OBESITY = "Obesity",
  CMR_OBESE = "Obesity",
  PARALYSIS = "Paralysis",
  CMR_PARALYSIS = "Paralysis",
  PVD = "Peripheral vascular disease",
  CMR_PERIVASC = "Peripheral vascular disease",
  PSYCHOSES = "Psychoses",
  CMR_PSYCHOSES = "Psychoses",
  PULMCIRC = "Pulmonary circulation disease",
  CMR_PULMCIRC = "Pulmonary circulation disease",
  RENALFAIL = "Renal failure and disease",
  CMR_RENLFL_MOD = "Renal failure and disease, moderate",
  CMR_RENLFL_MOD = "Renal failure and disease, severe",
  HYPOTHYROID = "Hypothyroidism",
  CMR_THYROID_HYPO = "Hypothyroidism",
  CMR_THYROID_OTH = "Other thyroid disorders",
  PEPTICULCER = "Peptic ulcer",
  CMR_ULCER_PEPTIC = "Peptic ulcer with bleeding",
  VALVDISEASE = "Valvular disease",
  CMR_VALVE = "Valvular disease",
  WEIGHTLOSS = "Weight loss",
  CMR_WGHTLOSS = "Weight loss",
  CARDARRHYT = "Cardiac arrhythmia",
  RHEUMATOIDARTH = "Rheumatoid arthritis",
  FLUIDELECTRO = "Fluid and electrolyte disorders"
)