R Markdown

PART 1

1. Creating a Vector

Vec1 <- 1:1000

2. Sampling

Vec2 <- sample(Vec1)

3. Creating a Data Frame

Dat <- data.frame(Vec1, Vec2)

4. Comparing Variables

cor(Dat)
##             Vec1        Vec2
## Vec1  1.00000000 -0.02697498
## Vec2 -0.02697498  1.00000000

5. Comment on whether you expected this correlation to be large or small (i.e. close to zero), and why.

I expected the correlation between Vec1 and Vec2 to be very small and close to zero because Vec2 was created by randomly shuffling the values from Vec1. Even though both of the vectors contain the same exact numbers (1 to 1,000), they are arranged in different orders. This would mean that when the value of Vec1 increases, the corresponding value in Vec2 does not consistently increase or decrease the same with it. Therefore, there is no strong linear relationship between the two variables. The correlation I got as an output was 0.03826187, which is very close to zero and supports my expectation that the two variables Vec1 and Vec2 have little to no linear correlation.

PART 2

1. Reading in Data

hdat <- read.csv("data_health_synth_small.csv")

2. Data size

nrow(hdat)
## [1] 48784
ncol(hdat)
## [1] 4

There are 48784 rows and 4 columns. The rows in the data set represent each individual person observed, and the columns represent the information gathered on each individual (their medical expenditures over the year, the patients race, if they are female, and lastly their mean systolic blood pressure over the year).

3. Summarize the Data

summary(hdat)
##       cost               race           female          bps_mean     
##  Min.   :     0   Length   :48784   Min.   :0.0000   Min.   :   0.0  
##  1st Qu.:  1200   N.unique :    2   1st Qu.:0.0000   1st Qu.: 118.0  
##  Median :  2800   N.blank  :    0   Median :1.0000   Median : 127.0  
##  Mean   :  7660   Min.nchar:    5   Mean   :0.6306   Mean   : 127.3  
##  3rd Qu.:  6600   Max.nchar:    5   3rd Qu.:1.0000   3rd Qu.: 136.0  
##  Max.   :550500                     Max.   :1.0000   Max.   :1323.0  
##                                                      NAs    :10668

report some results: The minimum medical expenditure is $0, the median is $2,800, and the mean is $7,660. The third quartile is $6,600, while the maximum is $550,500. The fact that the mean is substantially higher than the median suggests that some patients have very high medical expenditures. The mean for female is 0.6306, since the variable is coded as 0/1 for no/yes, this means that about 63.1 percent of observations are female=1. There are also 10,668 missing values in the mean systolic blood pressure category.

PART 3 Short Answer

The two curves show the average number of active chronic conditions for Black and White patients at different percentiles of the algorithm’s risk score. The purple line represents Black patients, and the orange line represents White patients. The curves move farther apart as the risk score increases, meaning that Black patients generally have more chronic conditions than the White patients with the same risk score. This is important because the algorithm was used to determine which patients would be referred for additional care. If the same risk-score threshold is applied to both groups, the divergence in the lines on the chart means that Black patients with a given number of chronic conditions may receive lower risk scores and therefore be less likely to be referred for additional care than similarly sick White patients. This shows how using healthcare costs as a proxy for healthcare needs can produce racial disparities.

* worked with Zayd Aslam