Author

Vagish Hemmige

The code in this script runs the statistical models used in the R/figures.R and R/tables.R scripts to generate tables and figures for the manuscript.

RcodeSource code

The full R script is available at:

This R script file is itself reliant on the following helper files:

The code sections below are imported directly from that script when this page is rendered.

Longitudinal cost data models

The following code runs models on the following outcomes as generated by the files in the R/postmatch_processing.R file, to calculate costs per month:

  • Total costs
  • Physician/supplier costs
  • Institutional total claims costs
  • Institutional Home Health costs
  • Institutional Inpatient costs
  • Institutional Outpatient costs
  • Institutional Skilled Nursing Facility costs
  • Institutional Dialysis costs
  • Institutional Auxiliary costs
  • Institutional Hospice costs

Analyzing cost data is notoriously challenging1. The VA Health Economics Resource Center has a practical guide, and whole textbooks cover the topic2.

To account for the repeated-observations nature of the data, both generalized estimating equations3 and mixed-effects models with patient as a random effect4 were explored.

Medical cost data are highly skewed, with many zeros. We explored linear models, log(cost) models5 and Tweedie models6.

Accounting for costs that are incomplete because follow-up ends, through loss of coverage or death, is itself a challenging topic, reviewed for health services researchers by Wijeysundera and colleagues7. Seminal methods papers include Lin and colleagues8 and Bang et al.

We trialed multiple types of models:

  • Naive estimation (patients do not contribute observations if uncovered or dead)
  • Treating post-death costs as zero, ignoring months with costs uncovered (note: not done yet)
  • Treating post-death costs as zero, weighting to adjust for uncovered months (note: not done yet)
Click to show/hide R Code
# Statistical modeling of cost data

temp_formula <- list()
fit <- list()

for (outcome in c("grand_total_cost_month", "IN_CLM_month_total", "PS_REV_month_total", "IN_CLM_month_groupedHomeHealth",
                  "IN_CLM_month_groupedHospice","IN_CLM_month_groupedNonclaimauxiliary","IN_CLM_month_groupedDialysis",
                  "IN_CLM_month_groupedOutpatient","IN_CLM_month_groupedInpatient","IN_CLM_month_groupedSkilledNursingFacility")){

  temp_formula[["glmmTMB"]][["untransformed"]]<-as.formula(
    paste0(
      outcome, " ~ ",
      "patient_type * factor(month) + ",
      "offset(log(month_offset)) + ",
      "(1 | USRDS_ID)"
    )
  )
  temp_formula[["gee"]][["untransformed"]]<-as.formula(
    paste0(
      outcome, " ~ ",
      "patient_type * factor(month) + ",
      "offset(log(month_offset))"
    )
  )

  temp_formula[["glmmTMB"]][["logtransformed"]] <- as.formula(
    paste0(
      "log1p(", outcome, ") ~ ",
      "patient_type * factor(month) + ",
      "offset(log(month_offset)) + ",
      "(1 | USRDS_ID)"
    )
  )
  temp_formula[["gee"]][["logtransformed"]]<-as.formula(
    paste0(
      "log1p(", outcome, ") ~ ",
      "patient_type * factor(month) + ",
      "offset(log(month_offset))"
    )
  )
  
  message(
    "Fitting models to formula: ", temp_formula[["glmmTMB"]][["untransformed"]]
  )
  
  message("Fitting glmmTMB to tweedie family...")
  fit[[outcome]][["glmmTMB"]][["tweedie"]] <- glmmTMB(
    temp_formula[["glmmTMB"]][["untransformed"]],
    family = tweedie(link = "log"),
    data = final_data_set
  )
  
  message("Fitting glmmTMB to linear family...")
  fit[[outcome]][["glmmTMB"]][["linear"]] <- glmmTMB(
    temp_formula[["glmmTMB"]][["untransformed"]],
    family = gaussian(link = "identity"),
    data = final_data_set
  )
  
  message("Fitting gee to linear family...")
  fit[[outcome]][["gee"]][["linear"]] <- geeglm(
    temp_formula[["gee"]][["untransformed"]],
    id     = USRDS_ID,
    data   = final_data_set,
    corstr = "exchangeable",
    family = gaussian(link = "identity"))  
  
  message(
    "Fitting models to formula: ", temp_formula[["glmmTMB"]][["logtransformed"]]
  )
  
  message("Fitting glmmTMB to logcost family...")
  fit[[outcome]][["glmmTMB"]][["log"]] <- glmmTMB(
    temp_formula[["glmmTMB"]][["logtransformed"]],
    family = gaussian(link = "identity"),
    data = final_data_set
  )
  
  message("Fitting gee to logcost family...")
  fit[[outcome]][["gee"]][["log"]] <- geeglm(
    temp_formula[["gee"]][["logtransformed"]],
    id     = USRDS_ID,
    data   = final_data_set,
    corstr = "exchangeable",
    family = gaussian(link = "identity"))  

  
}








#Currently not used (doesn't work)

fit[[outcome]][["gee"]][["tweedie"]] <- geeglm(
  temp_formula[["gee"]],
  id     = USRDS_ID,
  data   = final_data_set,
  corstr = "exchangeable",
  family = statmod::tweedie(
    var.power = 1.7
  ))

References

1.
Mihaylova B, Briggs A, O’Hagan A, Thompson SG. Review of statistical methods for analysing healthcare resources and costs. Health Econ. 2011;20(8):897-916. doi:10.1002/hec.1653
2.
Deb P, Norton EC, Manning WG. Health Econometrics Using Stata. Stata Press; 2017.
3.
Liang KY, Zeger SL. Longitudinal data analysis using generalized linear models. Biometrika. 1986;73(1):13-22. doi:10.1093/biomet/73.1.13
4.
Laird NM, Ware JH. Random-effects models for longitudinal data. Biometrics. 1982;38(4):963. doi:10.2307/2529876
5.
Manning WG, Mullahy J. Estimating log models: To transform or not to transform? J Health Econ. 2001;20(4):461-494. doi:10.1016/s0167-6296(01)00086-8
6.
Kurz CF. Tweedie distributions for fitting semicontinuous health care utilization cost data. BMC Med Res Methodol. 2017;17(1):171. doi:10.1186/s12874-017-0445-y
7.
Wijeysundera HC, Wang X, Tomlinson G, Ko DT, Krahn MD. Techniques for estimating health care costs with censored data: An overview for the health services researcher. Clinicoecon Outcomes Res. 2012;4:145-155. doi:10.2147/CEOR.S31552
8.
Lin DY, Feuer EJ, Etzioni R, Wax Y. Estimating medical costs from incomplete follow-up data. Biometrics. 1997;53(2):419-434.