Medicare Current Beneficiary Survey (MCBS)
The monitoring system for Medicare enrollees in the United States on topics not available in the program’s administrative data, such as out of pocket expenditure and beneficiary satisfaction.
Survey and supplemental tables with one row per sampled individual, although downloadable datasets not linkable.
A complex sample survey designed to generalize to all elderly and disabled individuals with at least one month of program enrollment during the calendar year.
Released annually as a public use file since 2015.
Conducted by the Office of Enterprise Data and Analytics (OEDA) of the Centers for Medicare & Medicaid Services (CMS) through a contract with NORC at the University of Chicago.
Please skim before you begin:
A haiku regarding this microdata:
Download, Import, Preparation
tf <- tempfile()
this_url <- "https://www.cms.gov/files/zip/cspuf2021.zip"
download.file( this_url , tf , mode = 'wb' )
unzipped_files <- unzip( tf , exdir = tempdir() )
mcbs_csv <- grep( '\\.csv$' , unzipped_files , value = TRUE )
mcbs_df <- read.csv( mcbs_csv )
names( mcbs_df ) <- tolower( names( mcbs_df ) )
Save Locally
Save the object at any point:
# mcbs_fn <- file.path( path.expand( "~" ) , "MCBS" , "this_file.rds" )
# saveRDS( mcbs_df , file = mcbs_fn , compress = FALSE )
Load the same object:
Variable Recoding
Add new columns to the data set:
mcbs_design <-
update(
mcbs_design ,
one = 1 ,
csp_age =
factor(
csp_age ,
levels = 1:3 ,
labels =
c(
'01: younger than 65' ,
'02: 65 to 74' ,
'03: 75 or older'
)
) ,
two_or_more_chronic_conditions = as.numeric( csp_nchrncnd > 1 ) ,
csp_sex = factor( csp_sex , labels = c( 'male' , 'female' ) )
)
Analysis Examples with the survey
library
Unweighted Counts
Count the unweighted number of records in the survey sample, overall and by groups:
Descriptive Statistics
Calculate the mean (average) of a linear variable, overall and by groups:
Calculate the distribution of a categorical variable, overall and by groups:
Calculate the sum of a linear variable, overall and by groups:
Calculate the weighted sum of a categorical variable, overall and by groups:
Calculate the median (50th percentile) of a linear variable, overall and by groups:
svyquantile( ~ pamtoop , mcbs_design , 0.5 )
svyby(
~ pamtoop ,
~ csp_age ,
mcbs_design ,
svyquantile ,
0.5 ,
ci = TRUE
)
Estimate a ratio:
Subsetting
Restrict the survey design to household income below $25,000:
Calculate the mean (average) of this subset:
Measures of Uncertainty
Extract the coefficient, standard error, confidence interval, and coefficient of variation from any descriptive statistics function result, overall and by groups:
this_result <- svymean( ~ pamtoop , mcbs_design )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
svyby(
~ pamtoop ,
~ csp_age ,
mcbs_design ,
svymean
)
coef( grouped_result )
SE( grouped_result )
confint( grouped_result )
cv( grouped_result )
Calculate the degrees of freedom of any survey design object:
Calculate the complex sample survey-adjusted variance of any statistic:
Include the complex sample design effect in the result for a specific statistic:
# SRS without replacement
svymean( ~ pamtoop , mcbs_design , deff = TRUE )
# SRS with replacement
svymean( ~ pamtoop , mcbs_design , deff = "replace" )
Compute confidence intervals for proportions using methods that may be more accurate near 0 and 1. See ?svyciprop
for alternatives:
Replication Example
This example matches the weighted total from the 2021 Data User’s Guide: Cost Supplement File Public Use File:
Analysis Examples with srvyr
The R srvyr
library calculates summary statistics from survey data, such as the mean, total or quantile using dplyr-like syntax. srvyr allows for the use of many verbs, such as summarize
, group_by
, and mutate
, the convenience of pipe-able functions, the tidyverse
style of non-standard evaluation and more consistent return types than the survey
package. This vignette details the available features. As a starting point for MCBS users, this code replicates previously-presented examples:
Calculate the mean (average) of a linear variable, overall and by groups: