Skip to content

Instantly share code, notes, and snippets.

@tyokota tyokota/src.R
Last active Jun 14, 2016

Embed
What would you like to do?
BRFSS
# thomasyokota[at]gmail.com
# project/purpose: CDC BRFSS in R for free.99
# DEPENDENCIES -----------------------------------------------------------------
install.packages('pacman')
pacman::p_load(RCurl, foreign, downloader, foreign)
# DATA -------------------------------------------------------------------------
source_url("https://raw.githubusercontent.com/ajdamico/asdfree/master/Download%20Cache/download%20cache.R", prompt=F, echo=F)
# download ez-pz brought to you by anthony joseph damico [ajdamico@gmail.com]
# note: brfss 2014
tf <- tempfile(); td <- tempdir()
xpt <- "http://www.cdc.gov/brfss/annual_data/2014/files/LLCP2014XPT.ZIP"
download_cached(xpt, tf, mode='wb')
local.fn <- unzip(tf, exdir=td)
brfss14 <- read.xport(local.fn)
# ANALYSIS----------------------------------------------------------------------
pacman::p_load(survey)
brfss.design14 <- svydesign(
weight = ~X_LLCPWT,
nest = TRUE,
strata = ~X_STSTR,
id = ~X_PSU,
data = brfss14)
# note: Told by a doctor or health professional that you have diabetes
# translation: eh, brah. You get diabetes or wat?
# http://health.hawaii.gov/brfss/files/2015/08/HBRFSS_2014_results.pdf
# page 91/200
svymean(~as.factor(DIABETE3), subset(brfss.design14, X_STATE==15))
# note: 95% confidence intervals
# translation: wea da confidence intervals stay bu?!
dm.hi <- svymean(~as.factor(DIABETE3), subset(brfss.design14, X_STATE==15))
se.row.pct <- sqrt(diag(attr(dm.hi, 'var')))
dm.hi - qnorm(0.975) * se.row.pct
dm.hi + qnorm(0.975) * se.row.pct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.