Research Question:

Is Quality of Life effected by not having health insurance?

Introduction

With the increase of political talk that has risen over the last decade in the United States - the impact of not having access to insurance on quality of life is something that should be discused frequently.

Explaining the Data

When looking into the Quality of Life there are a few things that first need to be understood about the data. Quality of Life in this data sets represents the number of physically unhealthy days per month that an individual reports. Health insurance in this data represents the number of person without insurance (population between the ages of 18-65 years old). Poor health represents adults that rported fair to poor health.

Loading The Data

library(readr)
library(dplyr)
library(ggplot2)
library(tidyverse)
library(nlme)
library(texreg)
library(nlme)
library(magrittr)
library(tidyr)
health <- read_csv("C:/Users/Meghan/Documents/health.csv")

Data

head(health)

Renaming The Data

health <- rename (health,
          "State" = Geo_STATE,
          "QualityOfLife" = SE_T001_001,
          "PoorHealth" = SE_T002_001,
          "NoInsurance" = SE_T006_002)
health1<- health %>% 
  filter(!is.na(State),!is.na(QualityOfLife),!is.na(PoorHealth),!is.na(NoInsurance))

How Many States?

length(unique(health1$State))
## [1] 51

How Many in Each State?

health1 %>% 
  group_by(State) %>% 
  summarise(NoInsurance = n())

Ecological Analysis

Summarizing the mean of Quality of Life by No Insurance and State

Stated <- health1 %>% 
  group_by(State) %>% 
  summarise(mean_p = mean(QualityOfLife, na.rm = TRUE), mean_s = mean(NoInsurance, na.rm = TRUE))
head(Stated)

In State 1, the mean Quality of Life perception of people by physically unhealthy days per month is 4.93 and the mean ofno insurance of people aged 18-65 is 21.04

ecoreg <- lm(mean_p ~ mean_s, data = Stated)
summary(ecoreg)
## 
## Call:
## lm(formula = mean_p ~ mean_s, data = Stated)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.7841 -0.3398  0.0035  0.1476  1.1406 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.43475    0.23004  10.584 2.96e-14 ***
## mean_s       0.06472    0.01131   5.721 6.28e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4682 on 49 degrees of freedom
## Multiple R-squared:  0.4005, Adjusted R-squared:  0.3882 
## F-statistic: 32.73 on 1 and 49 DF,  p-value: 6.278e-07

Complete Pooling Model

# cpooling <- gls(QualityOfLife ~ NoInsurance, data = health, method = "ML")
cpooling <- lm(QualityOfLife ~ NoInsurance, data = health1)
summary(cpooling)
## 
## Call:
## lm(formula = QualityOfLife ~ NoInsurance, data = health1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.97011 -0.46199 -0.03945  0.36118  2.39363 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 2.586855   0.037970   68.13   <2e-16 ***
## NoInsurance 0.058024   0.001721   33.71   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6344 on 3137 degrees of freedom
## Multiple R-squared:  0.2659, Adjusted R-squared:  0.2657 
## F-statistic:  1136 on 1 and 3137 DF,  p-value: < 2.2e-16

This model shows that No Insurance influences Quality of Life but, fallacy environment might have influence. Specific States and other outside factors may be an important determiant of more physically unhealthy days.

The Intercept

dcoef <- health1 %>% 
    group_by(State) %>% 
    do(mod = lm(QualityOfLife ~ NoInsurance, data = .))
coef <- dcoef %>% do(data.frame(intc = coef(.$mod)[1]))
ggplot(coef, aes(x = intc)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

This graph shows the average of physically sick days per individual.

The Slope

dcoef <- health1 %>% 
    group_by(State) %>% 
    do(mod = lm(QualityOfLife ~ NoInsurance, data = .))
coef <- dcoef %>% do(data.frame(sexc = coef(.$mod)[2]))
ggplot(coef, aes(x = sexc)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (stat_bin).

Random Intercept

m1_lme <- lme(QualityOfLife ~ NoInsurance, data = health1, random = ~1|State, method = "ML")
summary(m1_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: health1 
##        AIC      BIC    logLik
##   2769.137 2793.344 -1380.569
## 
## Random effects:
##  Formula: ~1 | State
##         (Intercept)  Residual
## StdDev:   0.4597771 0.3629689
## 
## Fixed effects: QualityOfLife ~ NoInsurance 
##                 Value  Std.Error   DF  t-value p-value
## (Intercept) 2.4048534 0.07356756 3087 32.68905       0
## NoInsurance 0.0663663 0.00171363 3087 38.72854       0
##  Correlation: 
##             (Intr)
## NoInsurance -0.458
## 
## Standardized Within-Group Residuals:
##         Min          Q1         Med          Q3         Max 
## -3.69889255 -0.60270699 -0.08666858  0.47079722  6.45560185 
## 
## Number of Observations: 3139
## Number of Groups: 51

Random intercept does not assume the affect to be diff. we only assume that the intercept follows a normal distribution. random= ~1 gives us the random State intercept. Random effects is divided into two parts residual and intercept. instead of plot 50 States intercept in this one we are forcing States to follow a normal intercept distribution.

Multi-Level Model #2

m2_lme <- lme(QualityOfLife ~ NoInsurance, data = health1, random = ~ NoInsurance|State, method = "ML")
summary(m2_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: health1 
##       AIC     BIC    logLik
##   2642.07 2678.38 -1315.035
## 
## Random effects:
##  Formula: ~NoInsurance | State
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev     Corr  
## (Intercept) 0.59031702 (Intr)
## NoInsurance 0.02205065 -0.63 
## Residual    0.35183631       
## 
## Fixed effects: QualityOfLife ~ NoInsurance 
##                 Value  Std.Error   DF  t-value p-value
## (Intercept) 2.3186544 0.09365957 3087 24.75619       0
## NoInsurance 0.0714299 0.00390826 3087 18.27667       0
##  Correlation: 
##             (Intr)
## NoInsurance -0.709
## 
## Standardized Within-Group Residuals:
##         Min          Q1         Med          Q3         Max 
## -3.91934494 -0.59196301 -0.07367605  0.47437336  5.48326031 
## 
## Number of Observations: 3139
## Number of Groups: 51

Random = ~ NoInsurance|State want to see random intercept and random affect of slope. Fixed affect gives the common trend shared by 50 States. States on average the average QualityOfLife index is 2.31 for those with no insurance on the otherhand the is subject to different States sand average of those with insurance is .07 more than. Random effect is uniquue to an individual State

Model Selection

# anova(cpooling, m1_lme, m2_lme)
AIC(cpooling, m1_lme, m2_lme)

Adding State Level Covariate

m3_lme <- lme(QualityOfLife ~ NoInsurance + PoorHealth, data = health1, random = ~ NoInsurance|State, method = "ML")
summary(m3_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: health1 
##         AIC      BIC   logLik
##   -2957.052 -2914.69 1485.526
## 
## Random effects:
##  Formula: ~NoInsurance | State
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev     Corr  
## (Intercept) 0.29510565 (Intr)
## NoInsurance 0.01221619 -0.631
## Residual    0.14323161       
## 
## Fixed effects: QualityOfLife ~ NoInsurance + PoorHealth 
##                 Value  Std.Error   DF   t-value p-value
## (Intercept) 1.6137030 0.04582527 3086  35.21426       0
## NoInsurance 0.0129617 0.00207832 3086   6.23663       0
## PoorHealth  0.1160882 0.00092971 3086 124.86561       0
##  Correlation: 
##             (Intr) NInsrn
## NoInsurance -0.642       
## PoorHealth  -0.122 -0.227
## 
## Standardized Within-Group Residuals:
##          Min           Q1          Med           Q3          Max 
## -5.478892767 -0.589978970 -0.003136943  0.615683636  3.929246109 
## 
## Number of Observations: 3139
## Number of Groups: 51

PoorHealth does of course effect QualityOfLife

Cross Level Interaction

m4_lme <- lme(QualityOfLife ~ NoInsurance*PoorHealth, data = health1, random = ~ NoInsurance|State, method = "ML")
summary(m4_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: health1 
##         AIC       BIC   logLik
##   -3253.043 -3204.629 1634.521
## 
## Random effects:
##  Formula: ~NoInsurance | State
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev     Corr  
## (Intercept) 0.28960712 (Intr)
## NoInsurance 0.01282924 -0.648
## Residual    0.13640632       
## 
## Fixed effects: QualityOfLife ~ NoInsurance * PoorHealth 
##                             Value  Std.Error   DF   t-value p-value
## (Intercept)             0.9447048 0.05862352 3085  16.11477       0
## NoInsurance             0.0383129 0.00256946 3085  14.91090       0
## PoorHealth              0.1614753 0.00271521 3085  59.47070       0
## NoInsurance:PoorHealth -0.0017586 0.00009942 3085 -17.68927       0
##  Correlation: 
##                        (Intr) NInsrn PrHlth
## NoInsurance            -0.776              
## PoorHealth             -0.638  0.468       
## NoInsurance:PoorHealth  0.644 -0.555 -0.945
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -6.5141026 -0.5739840  0.0139534  0.6016983  5.2169725 
## 
## Number of Observations: 3139
## Number of Groups: 51

By creating interaction between NoInsurance and PoorHealth fixed effect seem to be a significant interaction between NoInsurance and PoorHealth. On average the QualityOfLife index for a persons quality of life with no insurance that has is .28

Best Model

# anova(cpooling, m1_lme, m2_lme, m3_lme, m4_lme)
AIC(cpooling, m1_lme, m2_lme, m3_lme, m4_lme)

Centering Covariates

health1 %<>% mutate(cPoorHealth = PoorHealth - mean(PoorHealth))

Random intercept for State and slope for No Insurance with intearction with centered poor health

Refit The Model

m4a_lme <- lme(QualityOfLife ~ NoInsurance*cPoorHealth, data = health1, random = ~ NoInsurance|State, method = "ML")
summary(m4a_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: health1 
##         AIC       BIC   logLik
##   -3253.043 -3204.629 1634.521
## 
## Random effects:
##  Formula: ~NoInsurance | State
##  Structure: General positive-definite, Log-Cholesky parametrization
##             StdDev     Corr  
## (Intercept) 0.28960712 (Intr)
## NoInsurance 0.01282924 -0.648
## Residual    0.13640632       
## 
## Fixed effects: QualityOfLife ~ NoInsurance * cPoorHealth 
##                             Value  Std.Error   DF   t-value p-value
## (Intercept)              3.677020 0.04593068 3085  80.05587   0e+00
## NoInsurance              0.008555 0.00215225 3085   3.97503   1e-04
## cPoorHealth              0.161475 0.00271521 3085  59.47070   0e+00
## NoInsurance:cPoorHealth -0.001759 0.00009942 3085 -17.68927   0e+00
##  Correlation: 
##                         (Intr) NInsrn cPrHlt
## NoInsurance             -0.720              
## cPoorHealth              0.186 -0.180       
## NoInsurance:cPoorHealth -0.124  0.119 -0.945
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -6.5141026 -0.5739840  0.0139534  0.6016983  5.2169725 
## 
## Number of Observations: 3139
## Number of Groups: 51

On average the effect of no insurance on quality of life is 3.677

htmlreg(list(m4_lme, m4a_lme))
Statistical models
Model 1 Model 2
(Intercept) 0.94*** 3.68***
(0.06) (0.05)
NoInsurance 0.04*** 0.01***
(0.00) (0.00)
PoorHealth 0.16***
(0.00)
NoInsurance:PoorHealth -0.00***
(0.00)
cPoorHealth 0.16***
(0.00)
NoInsurance:cPoorHealth -0.00***
(0.00)
AIC -3253.04 -3253.04
BIC -3204.63 -3204.63
Log Likelihood 1634.52 1634.52
Num. obs. 3139 3139
Num. groups 51 51
p < 0.001, p < 0.01, p < 0.05

Intra Class Coorelation

m0_lme <- lme(QualityOfLife ~ 1, random = ~ 1|State, data = health1, method = "ML")
summary(m0_lme)
## Linear mixed-effects model fit by maximum likelihood
##  Data: health1 
##        AIC     BIC    logLik
##   3993.615 4011.77 -1993.808
## 
## Random effects:
##  Formula: ~1 | State
##         (Intercept)  Residual
## StdDev:   0.5828729 0.4409836
## 
## Fixed effects: QualityOfLife ~ 1 
##               Value  Std.Error   DF  t-value p-value
## (Intercept) 3.70787 0.08282065 3088 44.76987       0
## 
## Standardized Within-Group Residuals:
##         Min          Q1         Med          Q3         Max 
## -3.80510701 -0.60431801 -0.06023168  0.46724755  6.31715243 
## 
## Number of Observations: 3139
## Number of Groups: 51

.582/ (.5823+ .440)= .569 the difference of individual quality of life .569 between States.

Computing Confidence Intervals

intervals(m0_lme)
## Approximate 95% confidence intervals
## 
##  Fixed effects:
##                lower    est.    upper
## (Intercept) 3.545506 3.70787 3.870233
## attr(,"label")
## [1] "Fixed effects:"
## 
##  Random Effects:
##   Level: State 
##                     lower      est.     upper
## sd((Intercept)) 0.4779618 0.5828729 0.7108118
## 
##  Within-group standard error:
##     lower      est.     upper 
## 0.4301224 0.4409836 0.4521191

Overall Thoughts

Overall - what we have learned from exploring this data is that quality of life is effected by no insurance. And by quality of life we mean the number of sick days that someone reports. When someone does not necessarily have access to insurance, they remain sicker for longer. Although it is important to understand that sick days may also be a result of a numerous of outside factors not directly relating to not having access to insurance. But with the massive political talk about health insurance in the U.S it is something that is to be considered.

MerTools

library(merTools)
library(lme4)
m1 <- lme4::lmer(QualityOfLife ~  NoInsurance + PoorHealth + (1|State), data=health1)
(m1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: QualityOfLife ~ NoInsurance + PoorHealth + (1 | State)
##    Data: health1
## REML criterion at convergence: -2610.595
## Random effects:
##  Groups   Name        Std.Dev.
##  State    (Intercept) 0.2493  
##  Residual             0.1530  
## Number of obs: 3139, groups:  State, 51
## Fixed Effects:
## (Intercept)  NoInsurance   PoorHealth  
##    1.701051     0.007256     0.116841

We see from this analysis that the Quality of Life score difference between States is .24

 feEx <- FEsim(m1, 1000)
cbind(feEx[,1] , round(feEx[, 2:4], 3))

Illustrating Model Effects

plotFEsim(feEx) + 
  theme_bw() + labs(title = "Coefficient Plot of Health", 
                    x = "No Insurance", y = "Median Quality Of Life")

Random Effects

reEx <- REsim(m1)
head(reEx)
table(reEx$term)
## 
## (Intercept) 
##          51
table(reEx$groupFctr)
## 
## State 
##    51
p1 <- plotREsim(reEx)
p1

Here our Effect Ranges graph shows us that mostQuality Of Life scores vary greatly from our intercept zero, but there are extreme outliers with both high and low averages as well.