A case study, on determining an individual’s characteristics that influence its health expenditures, illustrates the regression modeling process from start to finish. Subsequently, the chapter summarizes what we learn from the modeling process, underscoring the importance of variable selection.
Case study: MEPS health expenditures
Video
Video Overhead Details
A Details. MEPS health expenditures
B Details. Overhead MEPS health expenditures
C Details. Outcome variable
D Details. Explanatory variables
E Details. Case study outline
Hide
A Details. MEPS health expenditures
This exercise considers data from the Medical Expenditure Panel Survey (MEPS), conducted by the U.S. Agency of Health Research and Quality. MEPS is a probability survey that provides nationally representative estimates of health care use, expenditures, sources of payment, and insurance coverage for the U.S. civilian population. This survey collects detailed information on individuals of each medical care episode by type of services including physician office visits, hospital emergency room visits, hospital outpatient visits, hospital inpatient stays, all other medical provider visits, and use of prescribed medicines. This detailed information allows one to develop models of health care utilization to predict future expenditures. You can learn more about MEPS at http://www.meps.ahrq.gov/mepsweb/ .
We consider MEPS data from the panels 7 and 8 of 2003 that consists of 18,735 individuals between ages 18 and 65. From this sample, we took a random sample of 2,000 individuals that appear in the file HealthExpend
. From this sample, there are 1,352 that had positive outpatient expenditures.
Our dependent variable is the amount of expenditures for outpatient visits, expendop
. For MEPS, outpatient events include hospital outpatient department visits, office-based provider visits and emergency room visits excluding dental services. (Dental services, compared to other types of health care services, are more predictable and occur in a more regular basis.) Hospital stays with the same date of admission and discharge, known as “zero-night stays,” were included in outpatient counts and expenditures. (Payments associated with emergency room visits that immediately preceded an inpatient stay were included in the inpatient expenditures. Prescribed medicines that can be linked to hospital admissions were included in inpatient expenditures, not in outpatient utilization.)
Hide
B Details. Overhead MEPS health expenditures
Data from the Medical Expenditure Panel Survey (MEPS), conducted by the U.S. Agency of Health Research and Quality (AHRQ).
A probability survey that provides nationally representative estimates of health care use, expenditures, sources of payment, and insurance coverage for the U.S. civilian population.
Collects detailed information on individuals of each medical care episode by type of services including
physician office visits,
hospital emergency room visits,
hospital outpatient visits,
hospital inpatient stays,
all other medical provider visits, and
use of prescribed medicines.
This detailed information allows one to develop models of health care utilization to predict future expenditures.
We consider MEPS data from the first panel of 2003 and take a random sample of n = 2, 000 individuals between ages 18 and 65.
Hide
C Details. Outcome variable
Our dependent variable is expenditures for outpatient admissions.
For MEPS, inpatient admissions include persons who were admitted to a hospital and stayed overnight.
In contrast, outpatient events include hospital outpatient department visits, office-based provider visits and emergency room visits excluding dental services.
Hospital stays with the same date of admission and discharge, known as “zero-night stays,” were included in outpatient counts and expenditures.
Payments associated with emergency room visits that immediately preceded an inpatient stay were included in the inpatient expenditures.
Prescribed medicines that can be linked to hospital admissions were included in inpatient expenditures, not in outpatient utilization.
Hide
D Details. Explanatory variables
9 variables in the database. Here 13 most relevant.
\[
{\small \begin{array}{ll}
expendop & \text{Amounts of expenditures for outpatient visits} \\
gender & \text{Indicate gender of patient (=1 if female, =0 if male)} \\
age & \text{Age in years between 18 and 65 }\\
race & \text{Race of patient described as Asian, Black, Native, White and other} \\
region & \text{Region of patient described as WEST, NORTHEAST, MIDWEST and SOUTH} \\
educ & \text{Level of education received described by words (LHIGHSC, HIGHSCH and COLLEGE)} \\
phstat & \text{Self-rated physical health status described as EXCE, VGOO, GOOD, FAIR and POOR} \\
mpoor & \text{Self-rated mental health (=1 if poor or fair, =0 if good to excellent mental health)} \\
anylimit & \text{Any activity limitation (=1 if any functional/activity limitation, =0 if otherwise)} \\
income & \text{Income compared to poverty line described as POOR, NPOOR, LINCOME, MINCOME and HINCOME} \\
insure & \text{Insurance coverage (=1 if covered by public/private health insurance in any month of 1996, =0 otherwise)} \\
usc & \text{1 if dissatisfied with one's usual source of care} \\
unemploy & \text{Employment status of patients} \\
managedcare & \text{1 if enrolled in an HMO or gatekeeper plan} \\
\end{array}}
\]
Hide
E Details. Case study outline
The next series of exercises leads you through an analysis of the steps for understanding a complex data set. Because of the complexity of the data, in each step only a sample of procedures will be executed.
The outline consists of:
Summary statistics
Splitting the data into training and testing portions with initial model fits
Selecting variables to be included in the model
Exercise. Summarizing data
Assignment Text
With a complex dataset, you will probably want to take a look at the structure of the data. You are already familiar with taking a [summary()] of a dataframe which provides summary statistics for many variables. You will see that several variables in this dataframe are categorical, or factor, variables. We can use the table() function to summarize them.
After getting a sense of the distributions of explanatory variables, we want to take a deeper dive into the distribution of the outcome variable, expendop
. We will do this by comparing the histograms of the variable to that of its logarithmic version.
To examine relationships of the outcome variable visually, we look to scatterplots for continuous variables (such as age
) and boxplots for categorical variables (such as phstat
).
Instructions
Examine the structure of the meps
dataframe using the str() function. Also, get a [summary()] of the dataframe.
Examine the distribution of the race
variable using the table() function.
Compare the expenditures distribution to its logarithmic version visually via histograms plotted next to another. par(mfrow = c(1, 2))
is used to organize the plots you create.
Examine the distribution of logarithmic expenditures in terms of levels of phstat
visually using the
boxplot() function.
Examine the relationship of age versus logarithmic expenditures using a scatter plot. Superimpose a local fitting line using the lines() and
lowess() functions.
eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6IiNtZXBzIDwtIHJlYWQuY3N2KFwiQ1NWRGF0YVxcXFxIZWFsdGhNZXBzLmNzdlwiLCBoZWFkZXIgPSBUUlVFKVxubWVwcyA8LSByZWFkLmNzdihcImh0dHBzOi8vYXNzZXRzLmRhdGFjYW1wLmNvbS9wcm9kdWN0aW9uL3JlcG9zaXRvcmllcy8yNjEwL2RhdGFzZXRzLzdiN2RhYjZkMGM1MjhlNGNkMmY4ZDBlMGZjNzgyNGEyNTQ0MjliZjgvSGVhbHRoTWVwcy5jc3ZcIiwgaGVhZGVyID0gVFJVRSkiLCJzYW1wbGUiOiIjIEV4YW1pbmUgdGhlIHN0cnVjdHVyZSBhbmQgZ2V0IGEgc3VtbWFyeSBvZiB0aGUgYG1lcHNgIGRhdGFmcmFtZSBcbnN0cihfX18pXG5zdW1tYXJ5KF9fXylcblxuIyBFeGFtaW5lIHRoZSBkaXN0cmlidXRpb24gb2YgdGhlIGByYWNlYCB2YXJpYWJsZSBcbnRhYmxlKF9fXylcblxuIyBDb21wYXJlIHRoZSBleHBlbmRpdHVyZXMgZGlzdHJpYnV0aW9uIHR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bmcgZXhlcmNpc2UuIFN1bW1hcnkgc3RhdGlzdGljcyBhcmUgYWxzbyBhIGtleSBwYXJ0IG9mIGFueSByZXBvcnQgYXMgdGhleSBpbGx1c3RyYXRlIGZlYXR1cmVzIG9mIHRoZSBkYXRhIHRoYXQgYXJlIGFjY2Vzc2libGUgdG8gYSBicm9hZCBhdWRpZW5jZS5cIikiLCJoaW50IjoiT25lIG9mIHRoZSBtb3N0IGltcG9ydGFudCBzdGVwcyBpbiBsaW5lYXIgcmVncmVzc2lvbiBpcyB1bmRlcnN0YW5kaW5nIHlvdXIgZGF0YS4gVXNpbmcgYSBjb21iaW5hdGlvbiBvZiA8Y29kZT5zdHIoKTwvY29kZT4gYW5kICA8Y29kZT5zdW1tYXJ5KCk8L2NvZGU+IGxldHMgeW91IHZpZXcgcXVhbnRpdGF0aXZlIHN0YXRpc3RpY3MgYWJvdXQgeW91ciBkYXRhLCB3aGlsZSA8Y29kZT5ib3hwbG90KCk8L2NvZGU+IGFuZCA8Y29kZT5oaXN0KCk8L2NvZGU+IGdpdmUgeW91IGEgbW9yZSB2aXN1YWwgcmVwcmVzZW50YXRpb24gb2YgeW91ciBkYXRhLiJ9
Exercise. Fit a benchmark multiple linear regression model
Assignment Text
As part of the pre-processing for the model fitting, we will split the data into training and test subsamples. For this exercise, we use a 75/25 split although other choices are certainly suitable. Some analysts prefer to do this splitting before looking at the data. Another approach, adopted here, is that the final report typically contains summary statistcs of the entire data set and so it makes sense to do so when examining summary statistics.
We start by fitting a benchmark model. It is common to use all available explanatory variables with the outcome on the original scale and so we use this as our benchmark model. This exercise shows that when you plot() a fitted linear regression model in R
, the result provides four graphs that you have seen before. These can be useful for identifying an appropriate model.
Instructions
Randomly split the data into a training and a testing data sets. Use 75% for the training, 25% for the testing.
Fit a full model using expendop
as the outcome and all explanatory variables. Summarize the results of this model fitting.
You can plot() the fitted model to view several diagnostic plots. These plots provide evidence that expenditures may not be the best scale for linear regression.
Fit a full model using logexpend
as the outcome and all explanatory variables and summarize the fit. Use the plot() function for evidence that this variable is more suited for linear regression methods than expenditures on the original scale.
Hint. A plot
of a regression object such as plot(mlr) provides four diagnostic plots. These can be organized as a 2 by 2 array using par(mfrow = c(2, 2))
.
eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6IiNtZXBzIDwtIHJlYWQuY3N2KFwiQ1NWRGF0YVxcXFxIZWFsdGhNZXBzLmNzdlwiLCBoZWFkZXIgPSBUUlVFKVxubWVwcyA8LSByZWFkLmNzdihcImh0dHBzOi8vYXNzZXRzLmRhdGFjYW1wLmNvbS9wcm9kdWN0aW9uL3JlcG9zaXRvcmllcy8yNjEwL2RhdGFzZXRzLzdiN2RhYjZkMGM1MjhlNGNkMmY4ZDBlMGZjNzgyNGEyNTQ0MjliZjgvSGVhbHRoTWVwcy5jc3ZcIiwgaGVhZGVyID0gVFJVRSlcbm1lcHMkbG9nZXhwZW5kIDwtIGxvZyhtZXBzJGV4cGVuZG9wKSIsInNhbXBsZSI6IiMgUmFuZG9tbHkgc3BsaXQgdGhlIGRhdGEgaW50byBhIHRyYWluaW5nIGFuZCBhIHRlc3RpbmcgZGF0YSBzZXRzLiBVc2UgNzVcXCUgZm9yIHRoZSB0cmFpbmluZywgMjVcXCUgZm9yIHRoZSB0ZXN0aW5nLlxubiA8LSBucm93KG1lcHMpXG5zZXQuc2VlZCgxMjM0NylcbnNodWZmbGVkX21lcHMgPC0gbWVwc1tzYW1wbGUobiksIF1cbnRyYWluX2luZGljZXMgPC0gMTpyb3VuZCgwLjc1ICogbilcbnRyYWluX21lcHMgICAgPC0gc2h1ZmZsZWRfbWVwc1t0cmFpbl9pbmRpY2VzLCBdXG50ZXN0X2luZGljZXMgIDwtIChyb3VuZCgwLjI1ICogbikgKyAxKTpuXG50ZXN0X21lcHMgICAgIDwtIHNodWZmbGVkX21lcHNbdGVzdF9pbmRpY2VzLCBdXG5cbiMgRml0IGEgZnVsbCBtb2RlbCB1c2luZyBgZXhwZW5kb3B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aWZmaWN1bHQgdG8gZGlhZ25vc2UgYW5kIGludGVycHJldCB3aXRob3V0IHByYWN0aWNlLlwiKSIsImhpbnQiOiJBIDxjb2RlPnBsb3Q8L2NvZGU+IG9mIGEgcmVncmVzc2lvbiBvYmplY3Qgc3VjaCBhcyBwbG90KG1scikgcHJvdmlkZXMgZm91ciBkaWFnbm9zdGljIHBsb3RzLiBUaGVzZSBjYW4gYmUgb3JnYW5pemVkIGFzIGEgMiBieSAyIGFycmF5IHVzaW5nIDxjb2RlPnBhcihtZnJvdyA9IGMoMiwgMikpPC9jb2RlPi4ifQ==
Exercise. Variable selection
Assignment Text
Modeling building can be approached using a “ground-up” strategy, where the analyst introduces a variable, examines residuls from a regression fit, and then seeks to understand the relationship between these residuals and other available variables so that these variables might be added to the model.
Another approach is a “top-down” strategy where all available variables are entered into a model and unnecessary variables are pruned from the model. Both approaches are helpful when using data to specify models. This exercise illustrates the latter approach, using the [step()] function to help narrow our search for the best fitting model.
Instructions
From our prior work, the training dataframe train_meps
has already been loaded in. A multiple linear regression model fit object meps_mlr2
is available that summarizes a fit of logexpend
as the outcome variable using all 13 explanatory variables.
Use the step() function function to drop unnecessary variables from the full fitted model summarized in the object meps_mlr2
and summarize this recommended model.
As an alternative, use the explanatory variables in the recommended model and add the varibles phstat
. Summarize the fit and note that statistical significance of the new variable.
You have been reminded by your boss that use of the variable gender
is unsuitable for actuarial pricing purposes. As an another alternative, drop gender
from the recommended model (still keeping phstat
). Note the statistical significance of the variable usc
with this fitted model.
eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6IiNtZXBzIDwtIHJlYWQuY3N2KFwiQ1NWRGF0YVxcXFxIZWFsdGhNZXBzLmNzdlwiLCBoZWFkZXIgPSBUUlVFKVxubWVwcyA8LSByZWFkLmNzdihcImh0dHBzOi8vYXNzZXRzLmRhdGFjYW1wLmNvbS9wcm9kdWN0aW9uL3JlcG9zaXRvcmllcy8yNjEwL2RhdGFzZXRzLzdiN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SwgZXRobmljaXR5IGFuZCBzb21ldGltZXMgc2V4IGFyZSBnb29kIGV4YW1wbGVzLiBUaGlzIGltcGxpZXMgdGhhdCBtb2RlbCBpbnRlcnByZXRhdGlvbiBjYW4gYmUganVzdCBhcyBpbXBvcnRhbnQgYXMgdGhlIGFiaWxpdHkgdG8gcHJlZGljdC5cIikiLCJoaW50IjoiU3RhcnRpbmcgd2l0aCBhIG1vZGVsIHRoYXQgY29uc2lzdHMgb2YgYWxsIHlvdXIgZXhwbGFuYXRvcnkgdmFyaWFibGVzIGFuZCB1c2luZyA8Y29kZT5zdGVwKCk8L2NvZGU+IGlzIGEgZ29vZCB3YXkgdG8gY3JlYXRlIGEgbW9kZWwgdGhhdCBmaXRzIHRoZSBkYXRhIHdlbGwuIE9uIHRoZSBvdGhlciBoYW5kLCB0aGlzIGlzIHNpbXBseSBzdGF0aXN0aWNzLCB3aGljaCBpcyB1bmFibGUgdG8gY2FwdHVyZSByZWFsIGV4cGxhbmF0aW9ucywgb3IgZm9sbG93IHJlZ3VsYXRvcnkgcnVsZXMuIn0=
Exercise. Model comparisons using cross-validation
Assignment Text
To compare alternative models, you decide to utilize cross-validation. For this exercise, you split the training sample into six subsamples of approximately equal size.
In the sample code, the cross-validation procedure has been summarized into a function that you can call. The input to the function is a list of variables that you select as your model explanatory variables. With this function, you can readily test several candidate models.
Instructions
Run the cross validation (crossvalfct
) function using the explanatory variables suggested by the stepwise function.
Run the function again but adding the mpoor
variable
Run the function again but omitting the gender
variable
Note which model is suggested by the cross validation function.
eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6IiNtZXBzIDwtIHJlYWQuY3N2KFwiQ1NWRGF0YVxcXFxIZWFsdGhNZXBzLmNzdlwiLCBoZWFkZXIgPSBUUlVFKVxubWVwcyA8LSByZWFkLmNzdihcImh0dHBzOi8vYXNzZXRzLmRhdGFjYW1wLmNvbS9wcm9kdWN0aW9uL3JlcG9zaXRvcmllcy8yNjEwL2RhdG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FsKGluY29ycmVjdF9tc2c9XCJNYWtlIHN1cmUgdG8gc3BlY2lmeSB0aGF0IHdlIHdhbnQgdGhlIGNyb3NzLXZhbGlkYXRpb24gc3RhdGlzdGljIGZvciBgZXhwbHZhc3IuM2AuXCIpXG5zdWNjZXNzX21zZyhcIkV4Y2VsbGVudCEgQ3Jvc3MtdmFsaWRhdGlvbiBoYXMgYmVjb21lIGFuIGVzc2VudGlhbCBwaWVjZSBvZiB0aGUgZGF0YSBhbmFseXN0cyB0b29sa2l0LiBHb29kIHRoYXQgeW91IG5vdyBoYXZlIGFkZGl0aW9uYWwgZXhwZXJpZW5jZSB3aXRoIGl0LlwiKSIsImhpbnQiOiJQZXJmb3JtaW5nIGNyb3NzLXZhbGlkYXRpb24gbWVhc3VyZXMgb24geW91ciBtb2RlbCBhbGxvd3MgeW91IHRvIHNlZSBob3cgd2VsbCBpdCBkb2VzIHdoZW4gaXQgY29tZXMgdG8gcHJlZGljdGluZyBvdXQgb2Ygc2FtcGxlIGRhdGEgcG9pbnRzLiJ9
Exercise. Out of sample validation
Assignment Text
From our prior work, the training train_meps
and test test_meps
dataframes have already been loaded in. We think our best model is based on logarithmic expenditures as the outcome and the following explanatory variables:
explvars3 <- c("gender", "age", "phstat", "anylimit", "insure", "mpoor")
We will compare this to a benchmark model that is based on expenditures as the outcome and all 13 explanatory variables
explvars4 <- c(explvars3, "race", "income", "region", "educ", "unemploy", "managedcare", "usc")
The comparisons will be based on expenditures in dollars using the held-out validation sample.
Instructions
Use the training sample to fit a linear model with logexpend
and explanatory variables listed in explvars3
Predict expenditures (not logged) for the test data and summarize the fit using the sum of absolute prediction errors.
Use the training sample to fit a benchmark linear model with expendop
and explanatory variables listed in explvars4
Predict expenditures for the test data and summarize the fit for the benchmark model using the sum of absolute prediction errors.
Compare the predictions of the models graphically.
eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6IiNtZXBzIDwtIHJlYWQuY3N2KFwiQ1NWRGF0YVxc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