DEM 7283

Professor C. Sparks

a) Binary outocme variable will be ‘shrtslep’ (short sleep duration). The variable ‘sleptim1’ which is the number of self-reported hours of sleep each night.

b) Research question: Does physical health influence short sleep duration? What factors as associated with short sleep duration?

c) Predictor variables: 1. mental health; 2. male status; 3. black race; 4. married status; 5. labor force participation

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(survey)
## Loading required package: grid
## Loading required package: Matrix
## Loading required package: survival
## 
## Attaching package: 'survey'
## The following object is masked from 'package:graphics':
## 
##     dotchart
load("~/Documents/1A_DEM Doctorate/DEM 7283/brfss16_mmsa.Rdata")
#names(brfss16m)

clean up variable names

cleannames<-tolower(gsub(pattern = "_", replacement = "", x= names(brfss16m))) 
names(brfss16m)<-cleannames

Recode variables

#recode the number of hours of sleep to binary
brfss16m$shrtslep<-Recode(brfss16m$sleptim1, recodes ="1:6=1; 7:24=0; else=NA")

#recode self rated health. Any day interfered with ADL then poor, all else good
brfss16m$physpoor<-Recode(brfss16m$physhlth, recodes ="1:30='poor'; 88='good'; else=NA")
brfss16m$mentpoor<-Recode(brfss16m$menthlth, recodes ="1:30='poor'; 88='good'; else=NA")

#recode sex variable to male or female
brfss16m$male<-Recode(brfss16m$sex, recodes="1='male'; 2='female'; else=NA")

#recode 5 level race/ethnicity to individual variables
brfss16m$black<-Recode(brfss16m$racegr3, recodes="2='nh black';9=NA; else='0nonblack'")
#brfss16m$white<-Recode(brfss16m$racegr3, recodes="1='nh white'; 9=NA; else='nonwhite'")
#brfss16m$other<-Recode(brfss16m$racegr3, recodes="3:4='other'; 9=NA; else='nonother'")
#brfss16m$hispanic<-Recode(brfss16m$racegr3, recodes="5='hispanic'; 9=NA; else='nonhispanic'")

#recode marital status
brfss16m$married<-Recode(brfss16m$marital, recodes="1='married'; 2:6='0not'; else=NA")

#recode employment
#brfss16m$employyes<-Recode(brfss16m$employ1, recodes="1:2='employed'; 3:4='unemployed';  else=NA")

#recode laborforce etc
brfss16m$laborforce<-Recode(brfss16m$employ1, recodes="1:4='labforce'; 5:8='0not';  else=NA")
#brfss16m$student<-Recode(brfss16m$employ1, recodes="6='student'; 9=NA;  else='not'")
#brfss16m$homemaker<-Recode(brfss16m$employ1, recodes="5='homemaker'; 9=NA;  else='not'")
#brfss16m$retired<-Recode(brfss16m$employ1, recodes="7='retired'; 9=NA;  else='not'")

#recode veteran status
#brfss16m$vetyes<-Recode(brfss16m$veteran3, recodes="1='veteran'; 2='not'; else=NA")

Chi-square tests

#Physical Health and short sleep duration
prop.table(table(brfss16m$shrtslep, brfss16m$physpoor), margin=2)
##    
##          good      poor
##   0 0.7184575 0.6159774
##   1 0.2815425 0.3840226
chisq.test(table(brfss16m$shrtslep, brfss16m$mentpoor))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(brfss16m$shrtslep, brfss16m$mentpoor)
## X-squared = 3866.9, df = 1, p-value < 2.2e-16
#Mental Health and short sleep duration
prop.table(table(brfss16m$shrtslep, brfss16m$mentpoor), margin=2)
##    
##          good      poor
##   0 0.7221679 0.5958662
##   1 0.2778321 0.4041338
chisq.test(table(brfss16m$shrtslep, brfss16m$mentpoor))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(brfss16m$shrtslep, brfss16m$mentpoor)
## X-squared = 3866.9, df = 1, p-value < 2.2e-16
#Sex and sleep deprivation
prop.table(table(brfss16m$shrtslep, brfss16m$male), margin=2)
##    
##        female      male
##   0 0.6835090 0.6779058
##   1 0.3164910 0.3220942
chisq.test(table(brfss16m$shrtslep, brfss16m$male))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(brfss16m$shrtslep, brfss16m$male)
## X-squared = 8.7292, df = 1, p-value = 0.003132
#Race/ethnicity and sleep deprivation
prop.table(table(brfss16m$shrtslep, brfss16m$black), margin=2)
##    
##     0nonblack  nh black
##   0 0.6955781 0.5600784
##   1 0.3044219 0.4399216
chisq.test(table(brfss16m$shrtslep, brfss16m$black))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(brfss16m$shrtslep, brfss16m$black)
## X-squared = 1862.2, df = 1, p-value < 2.2e-16
#prop.table(table(brfss16m$shrtslep, brfss16m$white), margin=2)
#chisq.test(table(brfss16m$shrtslep, brfss16m$white))

#prop.table(table(brfss16m$shrtslep, brfss16m$other), margin=2)
#chisq.test(table(brfss16m$shrtslep, brfss16m$other))

#prop.table(table(brfss16m$shrtslep, brfss16m$hispanic), margin=2)
#chisq.test(table(brfss16m$shrtslep, brfss16m$hispanic))
#Marital status and sleep deprivation
prop.table(table(brfss16m$shrtslep, brfss16m$married), margin=2)
##    
##          0not   married
##   0 0.6487241 0.7112246
##   1 0.3512759 0.2887754
chisq.test(table(brfss16m$shrtslep, brfss16m$married))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(brfss16m$shrtslep, brfss16m$married)
## X-squared = 1097, df = 1, p-value < 2.2e-16
#Labor Force Participation and sleep deprivation
prop.table(table(brfss16m$shrtslep, brfss16m$laborforce), margin=2)
##    
##          0not  labforce
##   0 0.7100490 0.6579762
##   1 0.2899510 0.3420238
chisq.test(table(brfss16m$shrtslep, brfss16m$laborforce))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(brfss16m$shrtslep, brfss16m$laborforce)
## X-squared = 752.06, df = 1, p-value < 2.2e-16
#prop.table(table(brfss16m$shrtslep, brfss16m$retired), margin=2)
#chisq.test(table(brfss16m$shrtslep, brfss16m$retired))

survey design object

brfss16mnew<-brfss16m%>%
  filter(is.na(mmsawt)==F)

options(survey.lonely.psu = "adjust")
des<-svydesign(ids=~1, weights=~mmsawt, data=brfss16mnew)

simple weighted analysis

library(questionr)
cat<-wtd.table(brfss16mnew$shrtslep, brfss16mnew$physpoor, weights = brfss16mnew$mmsawt)

prop.table(wtd.table(brfss16mnew$shrtslep, brfss16mnew$physpoor, weights = brfss16mnew$mmsawt), margin=2)
##        good      poor
## 0 0.6888723 0.5861390
## 1 0.3111277 0.4138610

not weighted

round(prop.table(table(brfss16m$shrtslep, brfss16m$physpoor), margin=2), digits=4)
##    
##       good   poor
##   0 0.7185 0.6160
##   1 0.2815 0.3840

compare with the OG

n<-table(is.na(brfss16mnew$shrtslep)==F)
n

FALSE TRUE 2768 246243

p<-prop.table(wtd.table(brfss16mnew$shrtslep, brfss16mnew$physpoor, weights=brfss16mnew$mmsawt), margin=2)
se<-(p*(1-p))/n[2]

stargazer(data.frame(proportion=p, se=sqrt(se)), summary = F, type ="html", digits=2)
proportion.Var1 proportion.Var2 proportion.Freq se.Var1 se.Var2 se.Freq
1 0 good 0.69 0 good 0.001
2 1 good 0.31 1 good 0.001
3 0 poor 0.59 0 poor 0.001
4 1 poor 0.41 1 poor 0.001

full sample design and weights

cat<-svytable(~shrtslep+physpoor, design =des)
stargazer (data.frame(prop.table(svytable(~shrtslep+physpoor, design =des), margin=2)), summary=F, type="html", digits=3)
shrtslep physpoor Freq
1 0 good 0.689
2 1 good 0.311
3 0 poor 0.586
4 1 poor 0.414
#table with variable mean values
sv.table<-svyby(formula= ~shrtslep, by = ~physpoor, design =des, FUN = svymean, na.rm=T)
stargazer(sv.table, summary =F, type = "html", digits =2)
physpoor shrtslep se
good good 0.31 0.002
poor poor 0.41 0.003

regression models

fit1<-lm(shrtslep~physpoor+mentpoor+male+black+married+laborforce, data=brfss16mnew) #not weighted

fit2<-lm(shrtslep~physpoor+mentpoor+male+black+married+laborforce, data=brfss16mnew, weights =mmsawt) #weighted

fit3<-svyglm(shrtslep~physpoor+mentpoor+male+black+married+laborforce, des, family=gaussian) #with survey design

#table with all the regression models
stargazer (fit1, fit2, fit3, style="demography", type="html", title ="Regression models for short sleep duration in labor force using survey data - BRFSS 2016", column.labels = c("OLS", "Weights Only", "Survey"), covariate.labels=c("poor physical health", "poor mental health", "nh male", "black", "married","in labforce"),  keep.stat="n", model.names=F, align=T, ci=T)
Regression models for short sleep duration in labor force using survey data - BRFSS 2016
shrtslep
OLS Weights Only Survey
Model 1 Model 2 Model 3
poor physical health 0.081*** 0.081*** 0.081***
(0.077, 0.085) (0.076, 0.085) (0.072, 0.089)
poor mental health 0.098*** 0.097*** 0.097***
(0.094, 0.103) (0.093, 0.101) (0.088, 0.106)
nh male 0.019*** 0.018*** 0.018***
(0.015, 0.022) (0.014, 0.022) (0.010, 0.026)
black 0.127*** 0.118*** 0.118***
(0.121, 0.133) (0.112, 0.124) (0.105, 0.131)
married -0.042*** -0.030*** -0.030***
(-0.046, -0.038) (-0.034, -0.026) (-0.038, -0.022)
in labforce 0.059*** 0.051*** 0.051***
(0.055, 0.063) (0.046, 0.055) (0.042, 0.059)
Constant 0.225*** 0.241*** 0.241***
(0.220, 0.229) (0.236, 0.246) (0.232, 0.250)
N 231,899 231,899 231,899
p < .05; p < .01; p < .001

Model 1 (unweighted) had differing estimates to Model 2 and Model 3 however they are all in the same direction. Model 2 and Model 3 estimates are the same with the difference that with the added survey design in Model 3 the confidence intervals are appropriately adjusted based on the administration of the survey (survey design) to more accurately reflect the true populaiton.

Haveing poor physical and mental health are positively associated with short sleep duration compared to good physical and mental health. Males compared to females are more likely to have short sleep duration. NH Black groups are more likely compared to report short sleep duration compared to Non Black groups. Being married is more likely associated with not reporting short sleep duration compared to the combined group of previously married and never married. Labor force participation is associated with reporting short sleep duration.