This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.countyhealthrankings.org/explore-health-rankings/our-methods/calculating-ranks | |
library(data.table) | |
chr = fread("https://www.countyhealthrankings.org/sites/default/files/media/document/analytic_data2022.csv", skip = 1) | |
# https://www.countyhealthrankings.org/sites/default/files/media/document/2022%20Ranked%20and%20Additional%20Measures%2C%20Data%20Sources%20and%20Years_0.pdf | |
measures = list( | |
# note some are reverse coded (see -ve weights) | |
health_behaviors = list( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: I have only tested this on 2016-2020 | |
# need `fs` and `readr` installed | |
#' Get NIS file specifications | |
#' | |
#' @description | |
#' Uses stata load files from hcup-us.ahrq.gov to get specs for loading NIS files | |
#' | |
#' @param year of interest | |
#' @param file "Core", "Hospital", or "Severity" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_fda <- function(dname, route){ | |
dname <- gsub(" ", "%", dname) | |
dname <- sprintf('"%s"', dname) # enclose in quotes | |
if (!missing(route) & !is.null(route)){ | |
dname <- sprintf('%s+AND+route:"%s"', dname, route) | |
} | |
url <- sprintf('https://api.fda.gov/drug/ndc.json?search=generic_name:%s&limit=100', dname) | |
res <- httr::GET(url)$content |> |