Skip to content

Instantly share code, notes, and snippets.

@stephenrho
Last active May 13, 2024 13:57
Show Gist options
  • Save stephenrho/8b1f8979f63fdf595590d9c101c0af9f to your computer and use it in GitHub Desktop.
Save stephenrho/8b1f8979f63fdf595590d9c101c0af9f to your computer and use it in GitHub Desktop.
# model from Sheyn et al. https://pubmed.ncbi.nlm.nih.gov/35830590/
# predictions recalibrated by Rhodea et al. [unpublished, will add link when published]
# set recalibrate = FALSE for original model
cms_model = function(Age, PVD=0, Diabetes_complicated=0, COPD=0,
Mesh=0, Abdominal_sacrocolpopexy=0, Sling=0,
Transfusion=0, Bowel_injury=0, Hemiplegia_or_paraplegia=0,
return_lin_pred=FALSE, recalibrate = TRUE, intercept = -2.18, slope = 0.66){
# Age = in years
# PVD = Current peripheral vascular disease
# Diabetes_complicated = Current diabetic complications
# COPD = Current chronic obstructive pulmonary disease (COPD)
# Mesh = Mesh prosthesis implanted during prolapse surgery
# Abdominal_sacrocolpopexy = Abdominal (laparotomy) sacrocolpopexy performed
# Sling = Sling performed
# Transfusion = Perioperative blood transfusion
# Bowel_injury = Intraoperative bowel injury
# Hemiplegia_or_paraplegia = Current hemiplegia or paraplegia
# return_lin_pred = return linear predictor (TRUE) or risk (FALSE)
# recalibrate = return recelibrated model predictions (TRUE) or original (FALSE)
# intercept, slope = logistic recalibration parameters (ignored if recalibrate = FALSE)
LP = -1.2905403 - 0.035923587 * Age + 0.00014583438 * pmax(Age - 57, 0)**3 -
0.001212714 * pmax(Age - 68, 0)**3 + 0.0014428642 * pmax(Age - 71, 0)**3 -
0.00041141731 * pmax(Age - 76, 0)**3 + 3.5432762e-05 * pmax(Age - 84, 0)**3 +
0.27159901 * PVD + 0.30138923 * Diabetes_complicated + 0.20282055 * COPD +
0.25400704 * Mesh + 0.82215628 * Abdominal_sacrocolpopexy +
0.46605468 * Sling + 1.0624051 * Transfusion + 1.036331 * Bowel_injury +
0.80865929 * Hemiplegia_or_paraplegia
if (recalibrate){
LP <- intercept + slope*LP
}
p = plogis(LP)
if (return_lin_pred){
return(LP)
} else{
return(p)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment