Documente Academic
Documente Profesional
Documente Cultură
July 9, 2017
1.0.3 Resources
Data source: https://data.medicare.gov/Hospital-Compare/Hospital-Readmission-
Reduction/9n3s-kdb3
More information: http://www.cms.gov/Medicare/medicare-fee-for-service-
payment/acuteinpatientPPS/readmissions-reduction-program.html
Markdown syntax: http://nestacms.com/docs/creating-content/markdown-cheat-sheet
****
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import bokeh.plotting as bkp
from scipy import stats
from mpl_toolkits.axes_grid1 import make_axes_locatable
import statsmodels.stats.api as sms
1
In [5]: # read in readmissions data provided
hospital_read_df = pd.read_csv('data/cms_hospital_readmissions.csv')
Out[12]: 16860
In [6]: hospital_read_df.head()
/Users/howellyu/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py:465: S
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
2
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/i
self.obj[item] = s
In [37]: # generate a scatterplot for number of discharges vs. excess rate of readm
# lists work better with matplotlib scatterplot function
x = [a for a in clean_hospital_read_df['Number of Discharges'][81:-3]]
y = list(clean_hospital_read_df['Excess Readmission Ratio'][81:-3])
fig, ax = plt.subplots(figsize=(8,5))
ax.scatter(x, y,alpha=0.2)
ax.set_xlim([0, max(x)])
ax.set_xlabel('Number of discharges', fontsize=12)
ax.set_ylabel('Excess rate of readmissions', fontsize=12)
ax.set_title('Scatterplot of number of discharges vs. excess rate of readm
ax.grid(True)
fig.tight_layout()
3
1.2 Preliminary Report
Read the following results/report. While you are reading it, think about if the conclusions are cor-
rect, incorrect, misleading or unfounded. Think about what you would change or what additional
analyses you would perform.
A. Initial observations based on the plot above + Overall, rate of readmissions is trending
down with increasing number of discharges + With lower number of discharges, there is a greater
incidence of excess rate of readmissions (area shaded red) + With higher number of discharges,
there is a greater incidence of lower rates of readmissions (area shaded green)
B. Statistics + In hospitals/facilities with number of discharges < 100, mean excess readmis-
sion rate is 1.023 and 63% have excess readmission rate greater than 1 + In hospitals/facilities
with number of discharges > 1000, mean excess readmission rate is 0.978 and 44% have excess
readmission rate greater than 1
C. Conclusions + There is a significant correlation between hospital capacity (number of dis-
charges) and readmission rates. + Smaller hospitals/facilities may be lacking necessary resources
to ensure quality care and prevent complications that lead to readmissions.
D. Regulatory policy recommendations + Hospitals/facilties with small capacity (< 300)
should be required to demonstrate upgraded resource allocation for quality care to continue oper-
ation. + Directives and incentives should be provided for consolidation of hospitals and facilities
to have a smaller number of them with higher capacity and number of discharges.
1.2.1 Exercise
Include your work on the following in this notebook and submit to your Github account.
A. Do you agree with the above analysis and recommendations? Why or why not?
B. Provide support for your arguments and your own recommendations with a statistically
sound analysis:
You can compose in notebook cells using Markdown: + In the control panel at the top,
choose Cell > Cell Type > Markdown + Markdown syntax: http://nestacms.com/docs/creating-
content/markdown-cheat-sheet
1.2.2 A.
In A. Initial Observation, we does not know whether the readmission rate is trending down as the
hospital capasity decreases since there is no calculation support, and visually we can hardly tell
whether readmission rate goes down.
4
In B. We cannot tell whether the mean of readmission rate is different for hospital with capacity
> 1000 and < 100. It is necessary to run a 2 sample t test before we make any conclusion and
therefore the conclusion made in C cannot be presumed correct.
1.2.3 B-1
H0 : There is NO difference of the means excess rate between hospital with capacity > 1000 and <
100.
print("The mean readmission rate of hospital with capacity < 100 is %.3f,
% round(mean_data_100, 3), "variance is %.5f,"% round(var_data_100,
"%.2f have excess readmission rate > 1." %
round(len(data_100[data_100["Excess Readmission Ratio"]>1])/len(data
print("The mean readmission rate of hospital with capacity > 1000 is %.3f
% round(mean_data_1000, 3), "variance is %.5f," % round(var_data_10
"%.2f have excess readmission rate > 1." %
round(len(data_1000[data_1000["Excess Readmission Ratio"]>1])/len(da
The mean readmission rate of hospital with capacity < 100 is 1.023, variance is 0.0
The mean readmission rate of hospital with capacity > 1000 is 0.978, variance is 0.
Their difference in mean is 0.044.
The calculation above is consistent with the number provided in Preliminary Report.
5
In [83]: pd.DataFrame.hist(data_100, column='Excess Readmission Ratio') # normal
6
In [84]: pd.DataFrame.hist(data_1000, column='Excess Readmission Ratio') # normal,
1.2.5 B-3.
Since p-value < 0.01, we reject the null hypothesis and conclude that there is a difference between
2 samples.
7
1.2.6 B-4. Statistical Significant Vs. Practical Significance
Althrough the difference between 2 samples has been proved to be statistically significant, which
means the will be correlation between the 2 variables, if we take a look at the confidence, we are
99% sure that the difference between the means of 2 samples will be caught between 0.029 and
0.059. Therefore, the difference is not enough to catch a true correlation in real life.
1. The statement There is a significant correlation between hospital capacity (number of
discharges) and readmission rates. is misleading since it does not consider the practical signifi-
cance.
2. The statement Smaller hospitals/facilities may be lacking necessary resources to ensure
quality care and prevent complications that lead to readmissions. may not be true since lower
discharge number does not necessarily imply that the hospital is small, even though in many cases
we might find this true.
#digitize() Return the indices of the bins to which each value in input a
plt.plot(groups.aggregate(lambda x: np.mean(x[x > 0.5]))['Number of Disch
list(groups.aggregate(lambda x: np.mean(x[x > 0.5]))['Excess Rea
color='b', lw=2, marker='s')
plt.xlabel('Number of discharges', fontsize=12)
plt.ylabel('Mean excess rate \nof readmissions', fontsize=12)
plt.title('Comparing binned discharges to \nmean excess rate of readmissi
plt.ylim(0.65,1.15)
plt.xlim(0, 7000)
plt.show()
8
9