BRFSS Data

Reviewing the 2017 BRFSS data.

Examining the relationship between social determinants of health and sleep in older adults (age 50+). We want to look at this relationship between AA and Caucasian Also, we want to examine the mediating role of HRQL on this relationship.

Variables of interest: Demographics, Sleep Disorders, Social Determinants of Health.

#Get 2017 BRFSS data
df<-read.csv("llcp2017.csv")

#Save data to LLCP_2017
LLCP_2017<-df

Identify which state(s) participated in the optional modules

#Identify variables from optional modules
#Find states that have answers to desired optional modules
StateCounts<-LLCP_2017 %>% 
            filter(SLEPTIM1 >= 1 & HOWSAFE1 >= 1) %>% 
            group_by(X_STATE) %>% 
            summarise()

#Subset States with optional modules
#27 = Minnesota. The only state that participated
LLCP_2017<- LLCP_2017 %>% 
  filter(X_STATE %in% StateCounts) 

Variable Selection and Descriptions

Study Variables

#Study variables necessary for analysis and weighting
StudyVars<-c("X_PSU","X_STSTR","X_LLCPWT","IMONTH")
  • X_PSU
    • Primary Sampling Unit (Equal to Annual Sequence Number)
  • X_STSTR
    • Sample Design Stratification Variable (Prior to 2011: _STSTR is a five digit number that combines the values for _STATE (first two characters), _GEOSTR (third and fourth character), and _DENSTR2 (final character)
  • X_LLCPWT
    • Final weight assigned to each respondent: Land-line and cell-phone data (Raking derived weight)
  • IMONTH
    • Month of interview

Demographic Variables

#Demographic Variables
DemoVars<-c("SEX","MARITAL","EDUCA","EMPLOY1","INCOME2","X_BMI5CAT",
            "X_RACE","X_AGEG5YR","CHILDREN","MSCODE","X_STATE")
  • SEX
    • 1- Male
    • 2- Female
    • 9- Refused
  • MARITAL
    • 1- Married
    • 2- Divorced
    • 3- Widowed
    • 4- Separated
    • 5- Never married
    • 6- A member of an unmarried couple
    • 9- Refused
    • BLANK -Not asked or Missing
  • EDUCA
    • 1- Never attended school or only kindergarten
    • 2- Grades 1 through 8 (Elementary)
    • 3- Grades 9 through 11 (Some high school)
    • 4- Grade 12 or GED (High school graduate)
    • 5- College 1 year to 3 years (Some college or technical school)
    • 6- College 4 years or more (College graduate)
    • 9- Refused
    • BLANK- Not asked or Missing
  • EMPLOY1
    • 1- Employed for wages
    • 2- Self-employed
    • 3- Out of work for 1 year or more
    • 4- Out of work for less than 1 year
    • 5- A homemaker
    • 6- A student
    • 7- Retired
    • 8- Unable to work
    • 9- Refused
    • BLANK- Not asked or missing
  • INCOME2
    • 1- Less than $10,000
    • 2- Less than $15,000 ($10,000 to less than $15,000)
    • 3- Less than $20,000 ($15,000 to less than $20,000)
    • 4- Less than $25,000 ($20,000 to less than $25,000)
    • 5- Less than $35,000 ($25,000 to less than $35,000)
    • 6- Less than $50,000 ($35,000 to less than $50,000)
    • 7- Less than $75,000 ($50,000 to less than $75,000)
    • 8- $75,000 or more
    • 77- Don’t know/Not Sure
    • 99- Refused
    • BLANK- Not asked or missing
  • X_BMI5CAT
    • 1- Underweight BMI< 18.5
    • 2- Normal Weight 18.5 <= BMI < 25
    • 3- Overweight 25 <= BMI < 30
    • 4- Obese 30<= BMI < 99
    • Blank- Don’t know/Refused/Missing
  • X_RACE
    • 1- White only, non-Hispanic
    • 2- Black only, non-Hispanic
    • 3- American Indian or Alaskan Native only, Non-Hispanic
    • 4- Asian only, non-Hispanic
    • 5- Native Hawaiian or other Pacific Islander only, Non-Hispanic
    • 6- Other race only, non-Hispanic
    • 7- Multiracial, non-Hispanic
    • 8- Hispanic
    • 9- Don’t know/Not sure/Refused
  • X_AGEG5YR
    • 1- Age 18 to 24
    • 2- Age 25 to 29
    • 3- Age 30 to 34
    • 4- Age 35 to 39
    • 5- Age 40 to 44
    • 6- Age 45 to 49
    • 7- Age 50 to 54
    • 8- Age 55 to 59
    • 9- Age 60 to 64
    • 10- Age 65 to 69
    • 11- Age 70 to 74
    • 12- Age 75 to 79
    • 13- Age 80 or older
    • 14- Don’t know/Refused/Missing
  • CHILDREN
    • 1-87 Number of children
    • 88- None
    • 77- Don’t know/Not sure
    • 99- Refused
  • MSCODE- Metropolitan Status Code
    • 1- In the center city of an MSA
    • 2- Outside the center city of an MSA but inside the county containing the center city
    • 3- Inside a suburban county of the MSA
    • 4- Not in an MSA

Sleep Variables

#Sleep optional modules
SleepVars<- c("SLEPTIM1","ADSLEEP")
  • SLEPTIM1 - ON average, how many hours of sleep do you get in a 24-hour period?
    • 1-24 hours
    • 77- Don’t know/Not sure
    • 99- Refused
    • BLANK- Missing
  • ADSLEEP- Over the last 2 weeks, how many days have you had trouble falling asleep or staying asleep or sleeping too much?
    • 1-14 days
    • 88- None
    • 77- Don’t know/Not sure
    • 99- Refused

Social Determinants of Health

#Social Determinants optional module
SDHVars<- c("SDHBILLS","HOWSAFE1","SDHFOOD","SDHMEALS","SDHMONEY","SDHSTRES")
  • SDHBILLS- During the last 12 months, was there a time when you were not able to pay your mortgage, rent or utility bills?
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • HOWSAFE1- How safe from crime do you consider your neighborhood to be?
    • 1- Extremely Safe
    • 2- Safe
    • 3- Unsafe
    • 4- Extremely Unsafe
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • SDHFOOD- “The food that I bought just didn’t last, and I didn’t have money to get more.” Was that often, sometimes, or never true for you in the last 12 months?
    • 1- Often True
    • 2- Sometimes True
    • 3- Never True
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • SDHMEALS- I couldn’t afford to eat balanced meals.” Was that often, sometimes, or never true for you in the last 12 months?
    • 1- Often True
    • 2- Sometimes True
    • 3- Never True
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • SDHMONEY- In general, how do your finances usually work out at the end of the month? Do you find that you usually:
    • 1- End up with some money left over
    • 2- Have just enough money to make ends meet
    • 3- Not have enough money to make ends meet
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • SDHSTRES- Question Prologue: Stress means a situation in which a person feels tense, restless, nervous, or anxious, or is unable to sleep at night because his/her mind is troubled all the time. Question: Within the last 30 days, how often have you felt this kind of stress?
    • 1- None of the time
    • 2- A little of the time
    • 3- Some of the time
    • 4- Most of the time
    • 5- All of the time
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing

Illness Variables

#Illness Modules
ILLNESSVars<-c("SMOKDAY2","ECIGNOW","CVDSTRK3","CVDCRHD4","DIABETE3","ADDEPEV2","HAVARTH3","CHCCOPD1")
  • SMOKDAY2- Do you now smoke cigarettes every day, some days, or not at all?
    • 1- Every day
    • 2- Some days
    • 3- Not at all
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • ECIGNOW-
    • 1- Every day
    • 2- Some days
    • 3- Not at all
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • CVDSTRK3- (Ever told) you had a stroke.
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • CVDCRHD4- (Ever told) you had angina or coronary heart disease?
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • DIABETE3- (Ever told) you have diabetes (If ´Yes´ and respondent is female, ask ´Was this only when you were pregnant?´. If Respondent says pre-diabetes or borderline diabetes, use response code 4.)
    • 1- Yes
    • 2- Yes, but female told only during pregnancy
    • 3- No
    • 4- No, pre-diabetes or borderline diabetes
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • ADDEPEV2- (Ever told) you that you have a depressive disorder, including depression, major depression, dysthymia, or minor depression?
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • HAVARTH3- (Ever told) you have some form of arthritis, rheumatoid arthritis, gout, lupus, or fibromyalgia? (Arthritis diagnoses include: rheumatism, polymyalgia rheumatica; osteoarthritis (not osteporosis); tendonitis, bursitis, bunion, tennis elbow; carpal tunnel syndrome, tarsal tunnel syndrome; joint infection, etc.)
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • CHCCOPD1- (Ever told) you have Chronic Obstructive Pulmonary Disease or COPD, emphysema or chronic bronchitis?
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing

Disability Variables

#Illness Modules
DisVars<-c("DEAF","BLIND", "DECIDE","DIFFWALK","DIFFDRES","DIFFALON")
  • DEAF-
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • BLIND-
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • DECIDE-
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • DIFFWALK-
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • DIFFDRES-
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing
  • DIFFALON-
    • 1- Yes
    • 2- No
    • 7- Don’t Know/Not sure
    • 9- Refused
    • BLANK- Not asked or Missing

Create Variable to Hold All Study Variables

#Decide which variables to keep
#Combine all variables into one variable
KeepVars<- c(DemoVars,SleepVars,SDHVars, HRQLVars,ILLNESSVars, DisVars, StudyVars)

Cleaning Variables

Functions for NA/Missing values

#Identify variables with 9- "Refused" . Convert to NA
Remove_9<- c("SEX", "MARITAL", "EDUCA", "EMPLOY1", "X_RACE")
#Function to recode "9" as NA
Remove_9_fun<-function(x){ifelse(x==9,NA,x)}


#Identify variables with 77- "Don't Know/Not Sure", 88- "None", and 99- "Refused".
Remove_77_88_99<- c("INCOME2", "CHILDREN","SLEPTIM1", "ADSLEEP", 
                 "PHYSHLTH","MENTHLTH","POORHLTH")
# Function to recode "77" and "99" as NA, "88" as 0 
Remove_77_88_99_fun<-function(x){ifelse(x %in% c(77,99),NA,ifelse(x==88,0,x))}



#Identify variables with 14- "Don't Know/Refused/Missing" . Convert to NA
Remove_14<- c("X_AGEG5YR")
#Function to recode "14" as NA
Remove_14_fun<-function(x){ifelse(x==14,NA,x)}


#Identify variables with 7,8,9- "Don't Know/Not Sure" or "Refused".
Remove_7_8_9<- c("SDHBILLS", "HOWSAFE1","SDHFOOD", "SDHMEALS","SDHMONEY", 
              "SDHSTRES","GENHLTH", "SMOKDAY2","ECIGNOW","CVDSTRK3","CVDCRHD4",   
              "DIABETE3","ADDEPEV2", "HAVARTH3", "CHCCOPD1", "DEAF","BLIND","DECIDE", 
              "DIFFWALK", "DIFFDRES", "DIFFALON")
# Function to recode "7","8", and  "9" as NA
Remove_7_8_9_fun<-function(x){ifelse(x %in% c(7:9),NA,x)}

Functions for Binary/Ordinal Values

# Identify variables with a 14 day scale
Day_Vars<-c("ADSLEEP")
Group_Days<-function(x){
    cut(x,breaks = c(-Inf,0,3,6,7,10,13,14),labels=c(0:6))
}

New Values. Will convert to Binary as well for 7 days and greater. - 0 = 0 days - 1 = 1-3 days - 2 = 4-6 days - 3 = 7 days - 4 = 8-10 days - 5 = 11-13 days - 6 = 14 days

Month_Vars<-c("PHYSHLTH","MENTHLTH","POORHLTH")
Group_Month_Fun<-function(x){
  cut(x,breaks = c(-Inf,0,6,13,20,29,Inf),labels=c(0:5))
}

New Values - 0 = 0 days - 1 = 1-6 days - 2 = 7-13 days - 3 = 14-20 days - 4 = 21-28 days - 5 = 29-31 days

Yes_No_Group<- c("SDHBILLS","CVDSTRK3","CVDCRHD4","DIABETE3","ADDEPEV2","HAVARTH3","CHCCOPD1",
               "DEAF","BLIND","DECIDE","DIFFWALK","DIFFDRES","DIFFALON")
Yes_1_Fun<-function(x){            
         as.numeric(recode(x, "1" = "1", .default = "0"))}

New Values - 1 = 1 - All else = 0

#Recoding for binary/logistic regressions
ref0<-c("CHILDREN")
fun0<- function(x){as.factor(recode(x,"88"="ref",.default="com",.missing="com"))}

ref1<-c("SEX","MARITAL","EMPLOY1","X_RACE","MSCODE","SDHBILLS","CVDSTRK3",
            "CVDCRHD4","DIABETE3","ADDEPEV2","HAVARTH3","CHCCOPD1",
            "DEAF","BLIND","DECIDE","DIFFWALK","DIFFDRES","DIFFALON")
fun1<- function(x){as.factor(recode(x,"1"="ref",.default="com",.missing="com"))}

ref2<-c("X_BMI5CAT")
fun2<- function(x){as.factor(recode(x,"2"="ref",.default="com",.missing="com"))}

ref4<-c("EDUCA")
fun4<- function(x){as.factor(recode(x,"4"="ref",.default="com",.missing="com"))}
  
ref6<-c("INCOME2")
fun6<- function(x){as.factor(recode(x,"6"="ref",.default="com",.missing="com"))}

ref7<-c("X_AGEG5YR")
fun7<- function(x){as.factor(recode(x,"7"="ref",.default="com",.missing="com"))}

ref12<-c("SDHFOOD","SDHMEALS","SMOKDAY2","ECIGNOW")
fun12<- function(x){as.factor(recode(x,"1"="ref","2"="ref",
                                          .default="com",.missing="com"))}
ref23<-c("SDHMONEY")
fun23<- function(x){as.factor(recode(x,"2"="ref","3"="ref",
                                          .default="com",.missing="com"))}
ref34<-c("HOWSAFE1")
fun34<- function(x){as.factor(recode(x,"3"="ref","4"="ref",
                                          .default="com",.missing="com"))}
ref45<-c("SDHSTRES","GENHLTH")
fun45<- function(x){as.factor(recode(x,"4"="ref","5"="ref",
                                          .default="com",.missing="com"))}
ref30<-c("PHYSHLTH","POORHLTH","MENTHLTH")
fun30<- function(x){as.factor(ifelse(x==88,"ref",ifelse(x<=13,"ref","com")))}

ref14<-c("ADSLEEP")
fun14<- function(x){as.factor(ifelse(x==88,"ref",ifelse(x<=6,"ref","com")))}

ref79<-c("SLEPTIM1")
fun79<- function(x){as.factor(ifelse(x %in% c(7:9),"ref","com"))}

Create Survey Objects

Descriptive Stats Survey

#Clean all variables
brfss_2017<- LLCP_2017 %>% 
  dplyr::select(KeepVars, -X_STATE) %>% 
  mutate_at(Remove_9,Remove_9_fun) %>% 
  mutate_at(Remove_77_88_99,Remove_77_88_99_fun) %>% 
  mutate_at(Remove_14,Remove_14_fun) %>% 
  mutate_at(Remove_7_8_9,Remove_7_8_9_fun) %>% 
  mutate_at(Day_Vars,Group_Days) %>% 
  mutate_at(Yes_No_Group,Yes_1_Fun) %>% 
  mutate_at(Month_Vars,Group_Month_Fun) %>% 
  mutate(SEX= as.factor(ifelse(SEX==1,"Male","Female")),
         MARITAL= factor(MARITAL,
          levels = c(1:6),
          labels = c("Married","Divorced","Widowed","Separated",
            "Never Married","Unmarried Couple")),
         EDUCA= factor(EDUCA,
          levels= c(1:6),
          labels = c("Never attended school or only kindergarten" , 
            "Grades 1 through 8 (Elementary)" ,
            "Grades 9 through 11 (Some high school)",
            "Grade 12 or GED (High school graduate)", 
            "College 1 year to 3 years (Some college or technical school)",
            "College 4 years or more (College graduate)"), ordered=TRUE),
         EMPLOY1= factor(EMPLOY1,
          levels=c(1:8),
          labels=c("Employed for wages","Self-Employed","Out of work for less than 1 year",
            "Out of work for 1 year or more", "A homemaker", "A student",
            "Retired","Unable to Work")),
         INCOME2=factor(INCOME2,
          levels= c(1:8),
          labels= c("Less than 10K","10 to 15K", "15 to 20K",
            "20 to 25K","25 to 35K","35 to 50K", "50 to 75K",
            "greater than 75K"), ordered=TRUE),
         X_RACE=factor(X_RACE,
          levels=c(1:8),
          labels=c("White only, non-Hispanic", "Black only, non-Hispanic",
            "American Indian or Alaskan Native Only, non-Hispanic", "Asian only, non-Hispanic",
            "Native Hawaiian or other Pacific Islander only, non-Hispanic",
            "Other race only, non-Hispanic","Multiracial, non-Hispanic","Hispanic")),
         MSCODE= factor(MSCODE,
          levels=c(1:4), 
          labels= c("In the center of an MSA",
            "Outside MSA center city but inside the center city county",
            "Inside a suburban county of the MSA", "Not in an MSA")),
         X_BMI5CAT= factor(X_BMI5CAT, 
          levels= c(1:4),
          labels=c("Underweight","Normal Weight","Overweight","Obese")),
         X_AGEG5YR= factor(X_AGEG5YR,
          levels= c(1:13),
          labels=c( "18 to 24",  "25 to 29",  "30 to 34", "35 to 39", "40 to 44",
            "45 to 49", "50 to 54", "55 to 59", "60 to 64","65 to 69","70 to 74", 
            "75 to 79", "80+"), ordered=TRUE),         
         CHILDREN=as.numeric(CHILDREN),
         SLEPTIM_B=ifelse(SLEPTIM1 %in% c(7:9),1,0),
         SLEPTIM1=ifelse(SLEPTIM1 %in% c(0:6),0,
                         ifelse(SLEPTIM1 %in% c(7:9),1,
                         ifelse(SLEPTIM1>=10,2,0))),
         SLEPTIM1=factor(SLEPTIM1,
            levels=c(0:2),
            labels=c("Less than 7 hours","7-9 hours","Greater than 9 hours")),
         ADSLEEP=factor(ADSLEEP,
                        levels=c(0:6),
                        labels=c("0 days","1-3 days","4-6 days","7 days",
                                 "8-10 days","11-13 days","14 days"),ordered = T),
         ADSLEEP_B= ifelse(ADSLEEP<"7 days",1,0), 
         HOWSAFE1= factor(HOWSAFE1,
            levels=c(1:4),
            labels=c("Extremely safe", "Safe", "Unsafe", "Extremely Unsafe") ,
            ordered= TRUE),
         SDHFOOD= factor(SDHFOOD,
            levels=c(1:3),
            labels=c("Often True","Sometimes True","Never True"), ordered= TRUE),
         SDHMEALS= factor(SDHMEALS,
            levels=c(1:3),
            labels=c("Often True","Sometimes True","Never True"), ordered= TRUE),
         SDHMONEY= factor(SDHMONEY,
            levels=c(1:3),
            labels=c("Often True","Sometimes True","Never True"), ordered= TRUE),
         SDHSTRES= factor(SDHSTRES,
            levels=c(1:5),
            labels=c("None of the time","A little of the time","Some of the time",
                     "Most of the time","All of the time"), ordered= TRUE),
         GENHLTH= factor(GENHLTH,
            levels=c(1:5),
            labels=c("Excellent","Very Good","Good","Fair","Poor"), ordered= TRUE),
         SMOKDAY2= factor(SMOKDAY2,
            levels=c(1:3),
            labels=c("Every day","Some days","Not at all"), ordered= TRUE),
         ECIGNOW= factor(ECIGNOW,
            levels=c(1:3),
            labels=c("Every day","Some days","Not at all"), ordered= TRUE))

#Create weighted survey
options(survey.lonely.psu = "adjust")
des<-svydesign(id=~X_PSU,strata=~X_STSTR,weights =~X_LLCPWT,data=brfss_2017,nest=T)

Regression Survey

# Build survey based on selected variables and binary functions
brfss2017B<- LLCP_2017 %>% 
  dplyr::select(KeepVars,-X_STATE) %>% 
  mutate(RACE=factor(X_RACE,
          levels=c(1:8),
          labels=c("White only, non-Hispanic", "Black only, non-Hispanic",
            "American Indian or Alaskan Native Only, non-Hispanic", "Asian only, non-Hispanic",
            "Native Hawaiian or other Pacific Islander only, non-Hispanic",
            "Other race only, non-Hispanic","Multiracial, non-Hispanic","Hispanic"))) %>% 
  mutate_at(ref0,fun0) %>% 
  mutate_at(ref1,fun1) %>% 
  mutate_at(ref2,fun2) %>% 
  mutate_at(ref4,fun4) %>% 
  mutate_at(ref6,fun6) %>% 
  mutate_at(ref7,fun7) %>% 
  mutate_at(ref12,fun12) %>% 
  mutate_at(ref23,fun23) %>% 
  mutate_at(ref34,fun34) %>% 
  mutate_at(ref45,fun45) %>% 
  mutate_at(ref30,fun30) %>% 
  mutate_at(ref14,fun14) %>% 
  mutate_at(ref79,fun79) 


#Create weighted survey
options(survey.lonely.psu = "adjust")
svydes<-svydesign(id=~X_PSU,strata=~X_STSTR,weights =~X_LLCPWT,data=brfss2017B,nest=T)

Data

Raw Data

DT::datatable(brfss_2017, options = list(scrollX=TRUE))

Unweighted

Unweighted_table<- tableby(X_RACE~., data= brfss_2017[,-c(37:42)], control = my_controls)
summary(Unweighted_table,labelTranslations = my_labels, 
        title="Unweighted Statistics")
Unweighted Statistics
White only, non-Hispanic (N=14917) Black only, non-Hispanic (N=466) American Indian or Alaskan Native Only, non-Hispanic (N=222) Asian only, non-Hispanic (N=308) Native Hawaiian or other Pacific Islander only, non-Hispanic (N=14) Other race only, non-Hispanic (N=55) Multiracial, non-Hispanic (N=176) Hispanic (N=645) Total (N=16803) p value
Sex 0.012
   Female 7896 (52.9%) 231 (49.6%) 129 (58.1%) 141 (45.8%) 7 (50.0%) 22 (40.0%) 80 (45.5%) 336 (52.1%) 8842 (52.6%)
   Male 7021 (47.1%) 235 (50.4%) 93 (41.9%) 167 (54.2%) 7 (50.0%) 33 (60.0%) 96 (54.5%) 309 (47.9%) 7961 (47.4%)
   Missing 0 0 0 0 0 0 0 0 0
Marital Status < 0.001
   Married 8511 (57.4%) 171 (37.0%) 69 (31.2%) 151 (49.2%) 5 (35.7%) 28 (53.8%) 61 (35.1%) 313 (48.8%) 9309 (55.7%)
   Divorced 1911 (12.9%) 64 (13.9%) 30 (13.6%) 12 (3.9%) 2 (14.3%) 6 (11.5%) 29 (16.7%) 51 (8.0%) 2105 (12.6%)
   Widowed 1471 (9.9%) 17 (3.7%) 14 (6.3%) 6 (2.0%) 1 (7.1%) 4 (7.7%) 10 (5.7%) 19 (3.0%) 1542 (9.2%)
   Separated 129 (0.9%) 16 (3.5%) 9 (4.1%) 1 (0.3%) 0 (0.0%) 2 (3.8%) 3 (1.7%) 30 (4.7%) 190 (1.1%)
   Never Married 2432 (16.4%) 188 (40.7%) 84 (38.0%) 129 (42.0%) 6 (42.9%) 11 (21.2%) 61 (35.1%) 162 (25.3%) 3073 (18.4%)
   Unmarried Couple 380 (2.6%) 6 (1.3%) 15 (6.8%) 8 (2.6%) 0 (0.0%) 1 (1.9%) 10 (5.7%) 66 (10.3%) 486 (2.9%)
   Missing 83 4 1 1 0 3 2 4 98
Education Level < 0.001
   Missing 34 0 3 3 0 4 0 5 49
   Never attended school or only kindergarten 3 (0.0%) 3 (0.6%) 1 (0.5%) 1 (0.3%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 18 (2.8%) 26 (0.2%)
   Grades 1 through 8 (Elementary) 84 (0.6%) 10 (2.1%) 3 (1.4%) 5 (1.6%) 0 (0.0%) 1 (2.0%) 0 (0.0%) 112 (17.5%) 215 (1.3%)
   Grades 9 through 11 (Some high school) 321 (2.2%) 31 (6.7%) 27 (12.3%) 5 (1.6%) 0 (0.0%) 1 (2.0%) 7 (4.0%) 86 (13.4%) 478 (2.9%)
   Grade 12 or GED (High school graduate) 3597 (24.2%) 140 (30.0%) 70 (32.0%) 56 (18.4%) 3 (21.4%) 19 (37.3%) 40 (22.7%) 165 (25.8%) 4090 (24.4%)
   College 1 year to 3 years (Some college or technical school) 4647 (31.2%) 145 (31.1%) 63 (28.8%) 67 (22.0%) 4 (28.6%) 16 (31.4%) 54 (30.7%) 138 (21.6%) 5134 (30.6%)
   College 4 years or more (College graduate) 6231 (41.9%) 137 (29.4%) 55 (25.1%) 171 (56.1%) 7 (50.0%) 14 (27.5%) 75 (42.6%) 121 (18.9%) 6811 (40.7%)
Employment < 0.001
   Employed for wages 7003 (47.3%) 253 (55.2%) 98 (46.2%) 187 (62.8%) 6 (42.9%) 24 (44.4%) 101 (57.7%) 349 (55.0%) 8021 (48.2%)
   Self-Employed 1451 (9.8%) 34 (7.4%) 11 (5.2%) 19 (6.4%) 3 (21.4%) 9 (16.7%) 8 (4.6%) 60 (9.5%) 1595 (9.6%)
   Out of work for less than 1 year 363 (2.5%) 17 (3.7%) 16 (7.5%) 8 (2.7%) 2 (14.3%) 2 (3.7%) 3 (1.7%) 15 (2.4%) 426 (2.6%)
   Out of work for 1 year or more 233 (1.6%) 27 (5.9%) 14 (6.6%) 7 (2.3%) 0 (0.0%) 1 (1.9%) 8 (4.6%) 26 (4.1%) 316 (1.9%)
   A homemaker 475 (3.2%) 11 (2.4%) 13 (6.1%) 8 (2.7%) 1 (7.1%) 1 (1.9%) 1 (0.6%) 73 (11.5%) 583 (3.5%)
   A student 318 (2.1%) 32 (7.0%) 5 (2.4%) 47 (15.8%) 2 (14.3%) 0 (0.0%) 14 (8.0%) 38 (6.0%) 456 (2.7%)
   Retired 4441 (30.0%) 55 (12.0%) 28 (13.2%) 11 (3.7%) 0 (0.0%) 14 (25.9%) 25 (14.3%) 40 (6.3%) 4614 (27.7%)
   Unable to Work 516 (3.5%) 29 (6.3%) 27 (12.7%) 11 (3.7%) 0 (0.0%) 3 (5.6%) 15 (8.6%) 33 (5.2%) 634 (3.8%)
   Missing 117 8 10 10 0 1 1 11 158
Income < 0.001
   Missing 2301 62 30 57 2 11 20 91 2574
   Less than 10K 301 (2.4%) 36 (8.9%) 24 (12.5%) 17 (6.8%) 0 (0.0%) 2 (4.5%) 5 (3.2%) 45 (8.1%) 430 (3.0%)
   10 to 15K 387 (3.1%) 20 (5.0%) 19 (9.9%) 8 (3.2%) 0 (0.0%) 3 (6.8%) 4 (2.6%) 42 (7.6%) 483 (3.4%)
   15 to 20K 634 (5.0%) 50 (12.4%) 18 (9.4%) 10 (4.0%) 2 (16.7%) 1 (2.3%) 11 (7.1%) 81 (14.6%) 807 (5.7%)
   20 to 25K 964 (7.6%) 67 (16.6%) 15 (7.8%) 28 (11.2%) 1 (8.3%) 5 (11.4%) 17 (10.9%) 86 (15.5%) 1183 (8.3%)
   25 to 35K 1214 (9.6%) 50 (12.4%) 25 (13.0%) 27 (10.8%) 0 (0.0%) 8 (18.2%) 20 (12.8%) 88 (15.9%) 1432 (10.1%)
   35 to 50K 1853 (14.7%) 63 (15.6%) 27 (14.1%) 24 (9.6%) 3 (25.0%) 13 (29.5%) 26 (16.7%) 78 (14.1%) 2087 (14.7%)
   50 to 75K 2275 (18.0%) 47 (11.6%) 33 (17.2%) 40 (15.9%) 3 (25.0%) 6 (13.6%) 21 (13.5%) 47 (8.5%) 2472 (17.4%)
   greater than 75K 4988 (39.5%) 71 (17.6%) 31 (16.1%) 97 (38.6%) 3 (25.0%) 6 (13.6%) 52 (33.3%) 87 (15.7%) 5335 (37.5%)
BMI Category < 0.001
   Underweight 188 (1.4%) 6 (1.5%) 6 (3.1%) 16 (6.0%) 1 (7.1%) 2 (4.1%) 2 (1.2%) 7 (1.6%) 228 (1.5%)
   Normal Weight 4296 (31.4%) 133 (32.6%) 35 (17.9%) 132 (49.6%) 8 (57.1%) 16 (32.7%) 34 (21.0%) 110 (24.7%) 4764 (31.3%)
   Overweight 5128 (37.4%) 141 (34.6%) 74 (37.8%) 80 (30.1%) 3 (21.4%) 18 (36.7%) 65 (40.1%) 173 (38.9%) 5682 (37.3%)
   Obese 4082 (29.8%) 128 (31.4%) 81 (41.3%) 38 (14.3%) 2 (14.3%) 13 (26.5%) 61 (37.7%) 155 (34.8%) 4560 (29.9%)
   Missing 1223 58 26 42 0 6 14 200 1569
Age Group < 0.001
   Missing 138 4 2 4 0 1 1 6 156
   18 to 24 854 (5.8%) 64 (13.9%) 25 (11.4%) 66 (21.7%) 1 (7.1%) 1 (1.9%) 25 (14.3%) 81 (12.7%) 1117 (6.7%)
   25 to 29 687 (4.6%) 49 (10.6%) 16 (7.3%) 50 (16.4%) 4 (28.6%) 5 (9.3%) 31 (17.7%) 70 (11.0%) 912 (5.5%)
   30 to 34 849 (5.7%) 57 (12.3%) 21 (9.5%) 46 (15.1%) 3 (21.4%) 6 (11.1%) 6 (3.4%) 72 (11.3%) 1060 (6.4%)
   35 to 39 878 (5.9%) 51 (11.0%) 14 (6.4%) 41 (13.5%) 0 (0.0%) 6 (11.1%) 22 (12.6%) 90 (14.1%) 1102 (6.6%)
   40 to 44 828 (5.6%) 40 (8.7%) 13 (5.9%) 21 (6.9%) 3 (21.4%) 5 (9.3%) 16 (9.1%) 76 (11.9%) 1002 (6.0%)
   45 to 49 946 (6.4%) 46 (10.0%) 21 (9.5%) 25 (8.2%) 2 (14.3%) 2 (3.7%) 13 (7.4%) 73 (11.4%) 1128 (6.8%)
   50 to 54 1327 (9.0%) 39 (8.4%) 31 (14.1%) 20 (6.6%) 0 (0.0%) 7 (13.0%) 12 (6.9%) 49 (7.7%) 1485 (8.9%)
   55 to 59 1616 (10.9%) 36 (7.8%) 24 (10.9%) 14 (4.6%) 0 (0.0%) 2 (3.7%) 14 (8.0%) 45 (7.0%) 1751 (10.5%)
   60 to 64 1805 (12.2%) 33 (7.1%) 24 (10.9%) 8 (2.6%) 0 (0.0%) 3 (5.6%) 11 (6.3%) 32 (5.0%) 1916 (11.5%)
   65 to 69 1673 (11.3%) 21 (4.5%) 18 (8.2%) 2 (0.7%) 0 (0.0%) 6 (11.1%) 10 (5.7%) 19 (3.0%) 1749 (10.5%)
   70 to 74 1295 (8.8%) 13 (2.8%) 8 (3.6%) 3 (1.0%) 0 (0.0%) 3 (5.6%) 5 (2.9%) 13 (2.0%) 1340 (8.0%)
   75 to 79 894 (6.0%) 4 (0.9%) 1 (0.5%) 3 (1.0%) 0 (0.0%) 0 (0.0%) 7 (4.0%) 10 (1.6%) 919 (5.5%)
   80+ 1127 (7.6%) 9 (1.9%) 4 (1.8%) 5 (1.6%) 1 (7.1%) 8 (14.8%) 3 (1.7%) 9 (1.4%) 1166 (7.0%)
Number of Children < 0.001
   Mean (SD) 0 (1) 1 (2) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 2) 0 (0, 2) 0 (0, 2) 0 (0, 1) 0 (0, 1) 0 (0, 1) 1 (0, 2) 0 (0, 1)
   Min - Max 0 - 11 0 - 10 0 - 8 0 - 6 0 - 3 0 - 7 0 - 6 0 - 12 0 - 12
   Missing 69 4 0 3 0 2 0 4 82
Metropolitan Status
   In the center of an MSA 2270 (59.7%) 75 (87.2%) 16 (64.0%) 40 (81.6%) 2 (100.0%) 8 (66.7%) 13 (59.1%) 46 (69.7%) 2470 (60.7%)
   Outside MSA center city but inside the center city county 391 (10.3%) 0 (0.0%) 2 (8.0%) 0 (0.0%) 0 (0.0%) 1 (8.3%) 1 (4.5%) 2 (3.0%) 397 (9.8%)
   Inside a suburban county of the MSA 1144 (30.1%) 11 (12.8%) 7 (28.0%) 9 (18.4%) 0 (0.0%) 3 (25.0%) 8 (36.4%) 18 (27.3%) 1200 (29.5%)
   Not in an MSA 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Missing 11112 380 197 259 12 43 154 579 12736
Hours of Sleep per Night < 0.001
   Less than 7 hours 3571 (27.3%) 165 (44.7%) 63 (36.8%) 68 (28.8%) 2 (22.2%) 18 (41.9%) 60 (40.3%) 156 (28.5%) 4103 (28.1%)
   7-9 hours 9145 (70.0%) 189 (51.2%) 102 (59.6%) 162 (68.6%) 7 (77.8%) 24 (55.8%) 84 (56.4%) 358 (65.3%) 10071 (69.0%)
   Greater than 9 hours 347 (2.7%) 15 (4.1%) 6 (3.5%) 6 (2.5%) 0 (0.0%) 1 (2.3%) 5 (3.4%) 34 (6.2%) 414 (2.8%)
   Missing 1854 97 51 72 5 12 27 97 2215
Days with difficulty sleeping < 0.001
   Missing 1993 99 49 76 5 11 31 102 2366
   0 days 6971 (53.9%) 214 (58.3%) 73 (42.2%) 140 (60.3%) 5 (55.6%) 16 (36.4%) 62 (42.8%) 315 (58.0%) 7796 (54.0%)
   1-3 days 2610 (20.2%) 63 (17.2%) 34 (19.7%) 55 (23.7%) 2 (22.2%) 13 (29.5%) 23 (15.9%) 83 (15.3%) 2883 (20.0%)
   4-6 days 1057 (8.2%) 24 (6.5%) 14 (8.1%) 13 (5.6%) 0 (0.0%) 5 (11.4%) 21 (14.5%) 44 (8.1%) 1178 (8.2%)
   7 days 385 (3.0%) 8 (2.2%) 8 (4.6%) 4 (1.7%) 0 (0.0%) 1 (2.3%) 5 (3.4%) 26 (4.8%) 437 (3.0%)
   8-10 days 450 (3.5%) 5 (1.4%) 8 (4.6%) 8 (3.4%) 1 (11.1%) 3 (6.8%) 8 (5.5%) 15 (2.8%) 498 (3.4%)
   11-13 days 129 (1.0%) 6 (1.6%) 2 (1.2%) 1 (0.4%) 0 (0.0%) 0 (0.0%) 2 (1.4%) 2 (0.4%) 142 (1.0%)
   14 days 1322 (10.2%) 47 (12.8%) 34 (19.7%) 11 (4.7%) 1 (11.1%) 6 (13.6%) 24 (16.6%) 58 (10.7%) 1503 (10.4%)
Bill Security < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 1888 102 49 72 6 11 29 101 2258
How safe from crime do you consider your neighborhood to be? < 0.001
   Missing 1922 103 53 71 6 11 31 108 2305
   Extremely safe 6621 (51.0%) 121 (33.3%) 48 (28.4%) 69 (29.1%) 1 (12.5%) 10 (22.7%) 66 (45.5%) 181 (33.7%) 7117 (49.1%)
   Safe 6097 (46.9%) 213 (58.7%) 96 (56.8%) 157 (66.2%) 6 (75.0%) 32 (72.7%) 63 (43.4%) 320 (59.6%) 6984 (48.2%)
   Unsafe 245 (1.9%) 21 (5.8%) 16 (9.5%) 11 (4.6%) 1 (12.5%) 2 (4.5%) 12 (8.3%) 32 (6.0%) 340 (2.3%)
   Extremely Unsafe 32 (0.2%) 8 (2.2%) 9 (5.3%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 4 (2.8%) 4 (0.7%) 57 (0.4%)
Food Security < 0.001
   Missing 1958 105 53 71 6 12 31 104 2340
   Often True 264 (2.0%) 25 (6.9%) 19 (11.2%) 12 (5.1%) 0 (0.0%) 2 (4.7%) 8 (5.5%) 25 (4.6%) 355 (2.5%)
   Sometimes True 756 (5.8%) 84 (23.3%) 27 (16.0%) 28 (11.8%) 1 (12.5%) 8 (18.6%) 23 (15.9%) 99 (18.3%) 1026 (7.1%)
   Never True 11939 (92.1%) 252 (69.8%) 123 (72.8%) 197 (83.1%) 7 (87.5%) 33 (76.7%) 114 (78.6%) 417 (77.1%) 13082 (90.5%)
Balanced Meals < 0.001
   Missing 1957 101 53 72 6 12 32 110 2343
   Often True 443 (3.4%) 34 (9.3%) 16 (9.5%) 11 (4.7%) 0 (0.0%) 2 (4.7%) 13 (9.0%) 28 (5.2%) 547 (3.8%)
   Sometimes True 935 (7.2%) 80 (21.9%) 34 (20.1%) 37 (15.7%) 1 (12.5%) 11 (25.6%) 29 (20.1%) 100 (18.7%) 1227 (8.5%)
   Never True 11582 (89.4%) 251 (68.8%) 119 (70.4%) 188 (79.7%) 7 (87.5%) 30 (69.8%) 102 (70.8%) 407 (76.1%) 12686 (87.7%)
Financial Security < 0.001
   Missing 2195 112 52 80 6 12 32 116 2605
   Often True 7933 (62.4%) 134 (37.9%) 60 (35.3%) 122 (53.5%) 2 (25.0%) 19 (44.2%) 66 (45.8%) 201 (38.0%) 8537 (60.1%)
   Sometimes True 4180 (32.9%) 166 (46.9%) 79 (46.5%) 91 (39.9%) 6 (75.0%) 17 (39.5%) 65 (45.1%) 257 (48.6%) 4861 (34.2%)
   Never True 609 (4.8%) 54 (15.3%) 31 (18.2%) 15 (6.6%) 0 (0.0%) 7 (16.3%) 13 (9.0%) 71 (13.4%) 800 (5.6%)
Within the last 30 days, how often have you felt stress? < 0.001
   Missing 2014 104 54 70 6 11 31 103 2393
   None of the time 6310 (48.9%) 162 (44.8%) 59 (35.1%) 106 (44.5%) 4 (50.0%) 13 (29.5%) 54 (37.2%) 224 (41.3%) 6932 (48.1%)
   A little of the time 3755 (29.1%) 86 (23.8%) 61 (36.3%) 67 (28.2%) 1 (12.5%) 18 (40.9%) 37 (25.5%) 138 (25.5%) 4163 (28.9%)
   Some of the time 1854 (14.4%) 60 (16.6%) 17 (10.1%) 45 (18.9%) 2 (25.0%) 7 (15.9%) 29 (20.0%) 124 (22.9%) 2138 (14.8%)
   Most of the time 686 (5.3%) 34 (9.4%) 17 (10.1%) 13 (5.5%) 1 (12.5%) 3 (6.8%) 13 (9.0%) 35 (6.5%) 802 (5.6%)
   All of the time 298 (2.3%) 20 (5.5%) 14 (8.3%) 7 (2.9%) 0 (0.0%) 3 (6.8%) 12 (8.3%) 21 (3.9%) 375 (2.6%)
General Health < 0.001
   Missing 27 2 1 0 0 1 0 2 33
   Excellent 2723 (18.3%) 109 (23.5%) 24 (10.9%) 70 (22.7%) 4 (28.6%) 12 (22.2%) 12 (6.8%) 116 (18.0%) 3070 (18.3%)
   Very Good 5631 (37.8%) 100 (21.6%) 50 (22.6%) 92 (29.9%) 3 (21.4%) 9 (16.7%) 51 (29.0%) 132 (20.5%) 6068 (36.2%)
   Good 4608 (30.9%) 171 (36.9%) 86 (38.9%) 114 (37.0%) 6 (42.9%) 23 (42.6%) 76 (43.2%) 240 (37.3%) 5324 (31.7%)
   Fair 1438 (9.7%) 60 (12.9%) 43 (19.5%) 27 (8.8%) 1 (7.1%) 6 (11.1%) 24 (13.6%) 126 (19.6%) 1725 (10.3%)
   Poor 490 (3.3%) 24 (5.2%) 18 (8.1%) 5 (1.6%) 0 (0.0%) 4 (7.4%) 13 (7.4%) 29 (4.5%) 583 (3.5%)
How many days during the past 30 days was your physical health not good? < 0.001
   0 9845 (67.1%) 331 (71.8%) 123 (56.4%) 216 (72.0%) 12 (85.7%) 38 (69.1%) 100 (57.5%) 465 (74.3%) 11130 (67.4%)
   1 2786 (19.0%) 59 (12.8%) 42 (19.3%) 55 (18.3%) 1 (7.1%) 11 (20.0%) 46 (26.4%) 83 (13.3%) 3083 (18.7%)
   2 524 (3.6%) 22 (4.8%) 12 (5.5%) 9 (3.0%) 0 (0.0%) 1 (1.8%) 6 (3.4%) 16 (2.6%) 590 (3.6%)
   3 498 (3.4%) 19 (4.1%) 11 (5.0%) 10 (3.3%) 1 (7.1%) 1 (1.8%) 6 (3.4%) 26 (4.2%) 572 (3.5%)
   4 152 (1.0%) 5 (1.1%) 6 (2.8%) 1 (0.3%) 0 (0.0%) 0 (0.0%) 1 (0.6%) 3 (0.5%) 168 (1.0%)
   5 862 (5.9%) 25 (5.4%) 24 (11.0%) 9 (3.0%) 0 (0.0%) 4 (7.3%) 15 (8.6%) 33 (5.3%) 972 (5.9%)
   Missing 250 5 4 8 0 0 2 19 288
How many days during the past 30 days was your mental health not good? < 0.001
   0 10440 (70.9%) 321 (69.3%) 124 (56.4%) 215 (71.0%) 8 (57.1%) 36 (65.5%) 90 (51.7%) 437 (68.9%) 11671 (70.3%)
   1 2538 (17.2%) 59 (12.7%) 37 (16.8%) 53 (17.5%) 3 (21.4%) 11 (20.0%) 35 (20.1%) 82 (12.9%) 2818 (17.0%)
   2 560 (3.8%) 26 (5.6%) 15 (6.8%) 14 (4.6%) 1 (7.1%) 2 (3.6%) 14 (8.0%) 40 (6.3%) 672 (4.1%)
   3 584 (4.0%) 24 (5.2%) 22 (10.0%) 14 (4.6%) 2 (14.3%) 3 (5.5%) 16 (9.2%) 35 (5.5%) 700 (4.2%)
   4 109 (0.7%) 7 (1.5%) 4 (1.8%) 3 (1.0%) 0 (0.0%) 0 (0.0%) 3 (1.7%) 6 (0.9%) 132 (0.8%)
   5 497 (3.4%) 26 (5.6%) 18 (8.2%) 4 (1.3%) 0 (0.0%) 3 (5.5%) 16 (9.2%) 34 (5.4%) 598 (3.6%)
   Missing 189 3 2 5 0 0 2 11 212
Poor health days 0.002
   0 4183 (59.5%) 91 (45.7%) 63 (46.3%) 72 (56.2%) 3 (50.0%) 15 (51.7%) 63 (58.3%) 154 (55.6%) 4644 (58.7%)
   1 1551 (22.1%) 48 (24.1%) 29 (21.3%) 29 (22.7%) 3 (50.0%) 6 (20.7%) 25 (23.1%) 64 (23.1%) 1755 (22.2%)
   2 348 (5.0%) 18 (9.0%) 16 (11.8%) 13 (10.2%) 0 (0.0%) 2 (6.9%) 5 (4.6%) 17 (6.1%) 419 (5.3%)
   3 428 (6.1%) 18 (9.0%) 12 (8.8%) 10 (7.8%) 0 (0.0%) 3 (10.3%) 7 (6.5%) 23 (8.3%) 501 (6.3%)
   4 91 (1.3%) 6 (3.0%) 4 (2.9%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 2 (1.9%) 2 (0.7%) 105 (1.3%)
   5 425 (6.0%) 18 (9.0%) 12 (8.8%) 4 (3.1%) 0 (0.0%) 3 (10.3%) 6 (5.6%) 17 (6.1%) 485 (6.1%)
   Missing 7891 267 86 180 8 26 68 368 8894
Do you smoke cigarettes every day, some days, or not at all? < 0.001
   Missing 8689 335 83 262 9 29 90 435 9932
   Every day 1319 (21.2%) 51 (38.9%) 52 (37.4%) 16 (34.8%) 1 (20.0%) 10 (38.5%) 25 (29.1%) 52 (24.8%) 1526 (22.2%)
   Some days 532 (8.5%) 34 (26.0%) 29 (20.9%) 5 (10.9%) 0 (0.0%) 0 (0.0%) 11 (12.8%) 44 (21.0%) 655 (9.5%)
   Not at all 4377 (70.3%) 46 (35.1%) 58 (41.7%) 25 (54.3%) 4 (80.0%) 16 (61.5%) 50 (58.1%) 114 (54.3%) 4690 (68.3%)
Do you use vaping products every day, some days, or not at all? 0.617
   Missing 12856 388 166 266 10 44 121 540 14391
   Every day 152 (7.4%) 3 (3.8%) 2 (3.6%) 1 (2.4%) 0 (0.0%) 0 (0.0%) 3 (5.5%) 5 (4.8%) 166 (6.9%)
   Some days 251 (12.2%) 15 (19.2%) 10 (17.9%) 6 (14.3%) 0 (0.0%) 0 (0.0%) 5 (9.1%) 13 (12.4%) 300 (12.4%)
   Not at all 1658 (80.4%) 60 (76.9%) 44 (78.6%) 35 (83.3%) 4 (100.0%) 11 (100.0%) 47 (85.5%) 87 (82.9%) 1946 (80.7%)
(Ever told) you had a stroke. 0.100
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 32 0 1 1 0 1 0 7 42
(Ever told) you had angina or coronary heart disease? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 101 1 2 6 0 1 1 6 118
(Ever told) you have diabetes < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 13 1 1 0 0 2 0 1 18
(Ever told) you that you have a depressive disorder? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 50 2 2 3 0 3 1 6 67
(Ever told) you have some form of arthritis? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 1) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 1) 0 (0, 0) 0 (0, 1)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 65 1 3 4 0 3 1 4 81
(Ever told) you have COPD, emphysema or chronic bronchitis? 0.019
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 51 0 3 4 0 4 1 3 66
Are you deaf or do you have serious difficulty hearing? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 302 17 14 16 2 2 7 17 377
Are you blind or do you have serious difficulty seeing, even when wearing glasses? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 329 18 13 20 2 2 7 17 408
Because of a physical, mental, or emotional condition, do you have serious difficulty concentrating, remembering, or making decisions? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 365 24 15 17 2 2 10 20 455
Do you have serious difficulty walking or climbing stairs? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 361 27 13 18 2 3 7 23 454
Do you have difficulty dressing or bathing? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 365 26 14 19 2 3 7 24 460
Because of a physical, mental, or emotional condition, do you have difficulty doing errands alone? < 0.001
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 407 29 14 20 2 3 9 25 509

Weighted

Weighted_Table<- tableby(X_RACE~., data=brfss_2017[,-c(37,38,40:42)], control = my_controls, 
                         weights = X_LLCPWT)
summary(Weighted_Table,labelTranslations = my_labels, 
        title="Weighted Statistics")
Weighted Statistics
White only, non-Hispanic (N=3501803) Black only, non-Hispanic (N=216193) American Indian or Alaskan Native Only, non-Hispanic (N=41207) Asian only, non-Hispanic (N=198660) Native Hawaiian or other Pacific Islander only, non-Hispanic (N=4531) Other race only, non-Hispanic (N=11248) Multiracial, non-Hispanic (N=44054) Hispanic (N=183148) Total (N=4200845)
Sex
   Female 1791248 (51.2%) 112199 (51.9%) 24276 (58.9%) 100861 (50.8%) 2470 (54.5%) 4795 (42.6%) 20200 (45.9%) 85074 (46.5%) 2141123 (51.0%)
   Male 1710556 (48.8%) 103993 (48.1%) 16931 (41.1%) 97799 (49.2%) 2062 (45.5%) 6453 (57.4%) 23853 (54.1%) 98074 (53.5%) 2059722 (49.0%)
   Missing 0 0 0 0 0 0 0 0 0
Marital Status
   Married 1992074 (57.2%) 77640 (36.5%) 13709 (33.7%) 86012 (43.3%) 1663 (36.7%) 6510 (59.0%) 13252 (30.8%) 87479 (47.9%) 2278338 (54.6%)
   Divorced 377418 (10.8%) 31135 (14.6%) 4689 (11.5%) 6895 (3.5%) 364 (8.0%) 965 (8.8%) 5227 (12.2%) 10594 (5.8%) 437287 (10.5%)
   Widowed 228935 (6.6%) 6572 (3.1%) 2889 (7.1%) 4365 (2.2%) 278 (6.1%) 415 (3.8%) 2058 (4.8%) 3450 (1.9%) 248964 (6.0%)
   Separated 26336 (0.8%) 7521 (3.5%) 1342 (3.3%) 745 (0.4%) 0 (0.0%) 269 (2.4%) 459 (1.1%) 8527 (4.7%) 45198 (1.1%)
   Never Married 735487 (21.1%) 86588 (40.7%) 15325 (37.7%) 93789 (47.3%) 2226 (49.1%) 2663 (24.1%) 19073 (44.4%) 45797 (25.1%) 1000949 (24.0%)
   Unmarried Couple 121376 (3.5%) 3374 (1.6%) 2742 (6.7%) 6681 (3.4%) 0 (0.0%) 210 (1.9%) 2888 (6.7%) 26797 (14.7%) 164067 (3.9%)
   Missing 20177 3363 512 172 0 215 1097 505 26041
Education Level
   Missing 6833 0 401 1103 0 367 0 1232 9936
   Never attended school or only kindergarten 1708 (0.0%) 3091 (1.4%) 380 (0.9%) 940 (0.5%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 6187 (3.4%) 12306 (0.3%)
   Grades 1 through 8 (Elementary) 33100 (0.9%) 9324 (4.3%) 59 (0.1%) 7334 (3.7%) 0 (0.0%) 284 (2.6%) 0 (0.0%) 46866 (25.8%) 96967 (2.3%)
   Grades 9 through 11 (Some high school) 146516 (4.2%) 25100 (11.6%) 9601 (23.5%) 7039 (3.6%) 0 (0.0%) 585 (5.4%) 3892 (8.8%) 41333 (22.7%) 234066 (5.6%)
   Grade 12 or GED (High school graduate) 911647 (26.1%) 70480 (32.6%) 13768 (33.7%) 50896 (25.8%) 888 (19.6%) 3867 (35.5%) 12644 (28.7%) 38673 (21.3%) 1102861 (26.3%)
   College 1 year to 3 years (Some college or technical school) 1263036 (36.1%) 66929 (31.0%) 10349 (25.4%) 50512 (25.6%) 2311 (51.0%) 4439 (40.8%) 12927 (29.3%) 31708 (17.4%) 1442210 (34.4%)
   College 4 years or more (College graduate) 1138964 (32.6%) 41269 (19.1%) 6650 (16.3%) 80836 (40.9%) 1333 (29.4%) 1706 (15.7%) 14591 (33.1%) 17149 (9.4%) 1302498 (31.1%)
Employment
   Employed for wages 1885983 (54.4%) 118052 (55.5%) 18140 (46.3%) 113427 (59.1%) 1702 (37.6%) 4355 (41.3%) 24207 (55.0%) 97391 (54.1%) 2263257 (54.6%)
   Self-Employed 338369 (9.8%) 18865 (8.9%) 3222 (8.2%) 14928 (7.8%) 529 (11.7%) 2115 (20.1%) 2600 (5.9%) 20843 (11.6%) 401472 (9.7%)
   Out of work for less than 1 year 80345 (2.3%) 6653 (3.1%) 2172 (5.5%) 6403 (3.3%) 489 (10.8%) 617 (5.9%) 542 (1.2%) 3194 (1.8%) 100415 (2.4%)
   Out of work for 1 year or more 57251 (1.7%) 13685 (6.4%) 2203 (5.6%) 3369 (1.8%) 0 (0.0%) 342 (3.2%) 2638 (6.0%) 6525 (3.6%) 86013 (2.1%)
   A homemaker 120193 (3.5%) 5519 (2.6%) 3689 (9.4%) 6996 (3.6%) 770 (17.0%) 422 (4.0%) 3 (0.0%) 23139 (12.9%) 160731 (3.9%)
   A student 138155 (4.0%) 17522 (8.2%) 783 (2.0%) 34826 (18.2%) 1040 (23.0%) 0 (0.0%) 4861 (11.0%) 12272 (6.8%) 209460 (5.0%)
   Retired 742711 (21.4%) 20410 (9.6%) 3824 (9.8%) 4093 (2.1%) 0 (0.0%) 2463 (23.4%) 3810 (8.7%) 8051 (4.5%) 785362 (18.9%)
   Unable to Work 102052 (2.9%) 12053 (5.7%) 5146 (13.1%) 7778 (4.1%) 0 (0.0%) 220 (2.1%) 5375 (12.2%) 8565 (4.8%) 141189 (3.4%)
   Missing 36745 3432 2028 6839 0 714 17 3169 52943
Income
   Missing 535283 30837 8505 34419 287 2522 7310 27852 647015
   Less than 10K 68250 (2.3%) 18639 (10.1%) 4589 (14.0%) 12020 (7.3%) 0 (0.0%) 269 (3.1%) 768 (2.1%) 13250 (8.5%) 117786 (3.3%)
   10 to 15K 71544 (2.4%) 11045 (6.0%) 3329 (10.2%) 6070 (3.7%) 0 (0.0%) 745 (8.5%) 887 (2.4%) 10928 (7.0%) 104549 (2.9%)
   15 to 20K 126466 (4.3%) 24376 (13.2%) 2164 (6.6%) 8851 (5.4%) 905 (21.3%) 284 (3.2%) 2894 (7.9%) 25461 (16.4%) 191402 (5.4%)
   20 to 25K 212524 (7.2%) 31198 (16.8%) 3271 (10.0%) 24506 (14.9%) 278 (6.6%) 697 (8.0%) 3921 (10.7%) 26461 (17.0%) 302856 (8.5%)
   25 to 35K 261969 (8.8%) 18297 (9.9%) 3582 (11.0%) 15936 (9.7%) 0 (0.0%) 1135 (13.0%) 3951 (10.8%) 28512 (18.4%) 333382 (9.4%)
   35 to 50K 409972 (13.8%) 29424 (15.9%) 5619 (17.2%) 17280 (10.5%) 998 (23.5%) 3466 (39.7%) 6285 (17.1%) 22791 (14.7%) 495835 (14.0%)
   50 to 75K 534070 (18.0%) 20708 (11.2%) 4845 (14.8%) 22563 (13.7%) 1221 (28.8%) 796 (9.1%) 5361 (14.6%) 9975 (6.4%) 599540 (16.9%)
   greater than 75K 1281724 (43.2%) 31668 (17.1%) 5303 (16.2%) 57015 (34.7%) 842 (19.8%) 1336 (15.3%) 12675 (34.5%) 17917 (11.5%) 1408481 (39.6%)
BMI Category
   Underweight 46541 (1.4%) 2336 (1.3%) 1511 (4.3%) 10990 (6.3%) 500 (11.0%) 168 (1.6%) 468 (1.1%) 2381 (2.0%) 64895 (1.7%)
   Normal Weight 1063252 (33.0%) 62399 (33.8%) 6826 (19.4%) 83460 (48.0%) 1988 (43.9%) 3606 (35.2%) 7643 (18.4%) 30497 (25.8%) 1259670 (33.3%)
   Overweight 1194439 (37.1%) 59527 (32.2%) 13026 (37.0%) 50244 (28.9%) 1223 (27.0%) 4458 (43.5%) 17589 (42.3%) 43066 (36.4%) 1383572 (36.5%)
   Obese 913025 (28.4%) 60413 (32.7%) 13845 (39.3%) 29070 (16.7%) 821 (18.1%) 2020 (19.7%) 15914 (38.2%) 42397 (35.8%) 1077505 (28.5%)
   Missing 284547 31519 6000 24895 0 996 2440 64806 415202
Age Group
   Missing 32265 3104 246 2600 0 15 340 1732 40302
   18 to 24 373807 (10.8%) 37212 (17.5%) 6814 (16.6%) 56270 (28.7%) 389 (8.6%) 7 (0.1%) 11094 (25.4%) 25055 (13.8%) 510649 (12.3%)
   25 to 29 226209 (6.5%) 22010 (10.3%) 3285 (8.0%) 31599 (16.1%) 1496 (33.0%) 1161 (10.3%) 5935 (13.6%) 20135 (11.1%) 311830 (7.5%)
   30 to 34 310213 (8.9%) 31118 (14.6%) 4253 (10.4%) 29081 (14.8%) 1341 (29.6%) 2078 (18.5%) 1408 (3.2%) 21926 (12.1%) 401419 (9.6%)
   35 to 39 276330 (8.0%) 22080 (10.4%) 1882 (4.6%) 26600 (13.6%) 0 (0.0%) 1125 (10.0%) 7446 (17.0%) 28735 (15.8%) 364199 (8.8%)
   40 to 44 251319 (7.2%) 19768 (9.3%) 1926 (4.7%) 10042 (5.1%) 731 (16.1%) 1559 (13.9%) 3507 (8.0%) 24905 (13.7%) 313757 (7.5%)
   45 to 49 235493 (6.8%) 19914 (9.3%) 3648 (8.9%) 11624 (5.9%) 497 (11.0%) 277 (2.5%) 1401 (3.2%) 17668 (9.7%) 290523 (7.0%)
   50 to 54 328689 (9.5%) 16472 (7.7%) 5049 (12.3%) 12309 (6.3%) 0 (0.0%) 1350 (12.0%) 2216 (5.1%) 12086 (6.7%) 378170 (9.1%)
   55 to 59 314909 (9.1%) 15132 (7.1%) 3980 (9.7%) 8615 (4.4%) 0 (0.0%) 716 (6.4%) 4506 (10.3%) 11705 (6.5%) 359563 (8.6%)
   60 to 64 342717 (9.9%) 13911 (6.5%) 5338 (13.0%) 5518 (2.8%) 0 (0.0%) 533 (4.7%) 2389 (5.5%) 8245 (4.5%) 378649 (9.1%)
   65 to 69 261477 (7.5%) 6686 (3.1%) 2490 (6.1%) 715 (0.4%) 0 (0.0%) 744 (6.6%) 1565 (3.6%) 4169 (2.3%) 277845 (6.7%)
   70 to 74 203406 (5.9%) 4363 (2.0%) 1572 (3.8%) 1310 (0.7%) 0 (0.0%) 594 (5.3%) 843 (1.9%) 2902 (1.6%) 214991 (5.2%)
   75 to 79 151771 (4.4%) 562 (0.3%) 132 (0.3%) 1058 (0.5%) 0 (0.0%) 0 (0.0%) 986 (2.3%) 2234 (1.2%) 156743 (3.8%)
   80+ 193200 (5.6%) 3860 (1.8%) 594 (1.4%) 1319 (0.7%) 77 (1.7%) 1089 (9.7%) 418 (1.0%) 1650 (0.9%) 202206 (4.9%)
Number of Children
   Mean (SD) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1) 1 (1)
   Median (Q1, Q3) 0 (0, 1) 1 (0, 2) 0 (0, 2) 1 (0, 2) 1 (0, 3) 0 (0, 1) 0 (0, 1) 1 (0, 2) 0 (0, 1)
   Min - Max 0 - 11 0 - 10 0 - 8 0 - 6 0 - 3 0 - 7 0 - 6 0 - 12 0 - 12
   Missing 19040 3577 0 2165 0 728 0 1039 26549
Metropolitan Status
   In the center of an MSA 449781 (55.7%) 21117 (84.9%) 2870 (38.4%) 19867 (77.0%) 287 (100.0%) 1877 (72.7%) 2723 (65.9%) 9853 (65.0%) 508375 (57.2%)
   Outside MSA center city but inside the center city county 95126 (11.8%) 0 (0.0%) 710 (9.5%) 0 (0.0%) 0 (0.0%) 146 (5.7%) 205 (5.0%) 542 (3.6%) 96729 (10.9%)
   Inside a suburban county of the MSA 263022 (32.6%) 3760 (15.1%) 3903 (52.2%) 5920 (23.0%) 0 (0.0%) 559 (21.6%) 1205 (29.2%) 4766 (31.4%) 283135 (31.9%)
   Not in an MSA 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Missing 2693874 191316 33725 172874 4244 8666 39920 167987 3312605
Hours of Sleep per Night
   Less than 7 hours 870879 (28.5%) 73155 (43.6%) 9591 (31.0%) 44672 (29.4%) 753 (23.9%) 3911 (47.4%) 15116 (41.1%) 41728 (26.6%) 1059803 (29.4%)
   7-9 hours 2114591 (69.2%) 89135 (53.2%) 18603 (60.2%) 101733 (66.9%) 2402 (76.1%) 4296 (52.1%) 19967 (54.2%) 104331 (66.5%) 2455060 (68.0%)
   Greater than 9 hours 69664 (2.3%) 5310 (3.2%) 2723 (8.8%) 5648 (3.7%) 0 (0.0%) 40 (0.5%) 1729 (4.7%) 10782 (6.9%) 95896 (2.7%)
   Missing 446669 48592 10291 46607 1377 3001 7243 26307 590086
Days with difficulty sleeping
   Missing 480498 51438 9933 47495 1377 2804 8521 29224 631290
   0 days 1605295 (53.1%) 98303 (59.7%) 13662 (43.7%) 92409 (61.1%) 1132 (35.9%) 3009 (35.6%) 14035 (39.5%) 96948 (63.0%) 1924792 (53.9%)
   1-3 days 601393 (19.9%) 26430 (16.0%) 6098 (19.5%) 36571 (24.2%) 601 (19.1%) 1528 (18.1%) 5251 (14.8%) 20276 (13.2%) 698150 (19.6%)
   4-6 days 265813 (8.8%) 10344 (6.3%) 4131 (13.2%) 6745 (4.5%) 0 (0.0%) 1344 (15.9%) 7043 (19.8%) 12211 (7.9%) 307630 (8.6%)
   7 days 94054 (3.1%) 2819 (1.7%) 1001 (3.2%) 1273 (0.8%) 0 (0.0%) 765 (9.1%) 1297 (3.6%) 6919 (4.5%) 108126 (3.0%)
   8-10 days 114739 (3.8%) 1680 (1.0%) 1809 (5.8%) 4846 (3.2%) 651 (20.6%) 120 (1.4%) 1148 (3.2%) 3495 (2.3%) 128489 (3.6%)
   11-13 days 30131 (1.0%) 3301 (2.0%) 54 (0.2%) 884 (0.6%) 0 (0.0%) 0 (0.0%) 289 (0.8%) 405 (0.3%) 35065 (1.0%)
   14 days 309880 (10.3%) 21879 (13.3%) 4519 (14.4%) 8437 (5.6%) 770 (24.4%) 1677 (19.9%) 6470 (18.2%) 13669 (8.9%) 367302 (10.3%)
Bill Security
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (1) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 464166 51109 9479 46205 1766 2804 7580 28651 611759
How safe from crime do you consider your neighborhood to be?
   Missing 473537 51169 10134 45022 1766 2804 8186 29064 621684
   Extremely safe 1498980 (49.5%) 53616 (32.5%) 9553 (30.7%) 45948 (29.9%) 500 (18.1%) 1832 (21.7%) 14887 (41.5%) 49330 (32.0%) 1674646 (46.8%)
   Safe 1459253 (48.2%) 97343 (59.0%) 17796 (57.3%) 100773 (65.6%) 1614 (58.4%) 5570 (66.0%) 17353 (48.4%) 93027 (60.4%) 1792728 (50.1%)
   Unsafe 60213 (2.0%) 10252 (6.2%) 2555 (8.2%) 6917 (4.5%) 651 (23.5%) 1041 (12.3%) 3041 (8.5%) 10762 (7.0%) 95433 (2.7%)
   Extremely Unsafe 9820 (0.3%) 3814 (2.3%) 1169 (3.8%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 587 (1.6%) 964 (0.6%) 16354 (0.5%)
Food Security
   Missing 478911 53169 9765 44873 1766 2865 8118 28481 627948
   Often True 69410 (2.3%) 12380 (7.6%) 3782 (12.0%) 8433 (5.5%) 0 (0.0%) 589 (7.0%) 1883 (5.2%) 6732 (4.4%) 103209 (2.9%)
   Sometimes True 202443 (6.7%) 42573 (26.1%) 5692 (18.1%) 19722 (12.8%) 770 (27.9%) 1897 (22.6%) 6792 (18.9%) 28138 (18.2%) 308028 (8.6%)
   Never True 2751039 (91.0%) 108071 (66.3%) 21968 (69.9%) 125632 (81.7%) 1995 (72.1%) 5897 (70.3%) 27261 (75.9%) 119797 (77.5%) 3161660 (88.5%)
Balanced Meals
   Missing 478990 50242 9765 44835 1766 3029 8593 30475 627694
   Often True 113176 (3.7%) 15365 (9.3%) 1702 (5.4%) 5904 (3.8%) 0 (0.0%) 592 (7.2%) 3891 (11.0%) 6144 (4.0%) 146775 (4.1%)
   Sometimes True 264022 (8.7%) 38254 (23.1%) 6835 (21.7%) 27453 (17.8%) 500 (18.1%) 2216 (27.0%) 7655 (21.6%) 27339 (17.9%) 374273 (10.5%)
   Never True 2645616 (87.5%) 112333 (67.7%) 22905 (72.8%) 120468 (78.3%) 2266 (81.9%) 5411 (65.8%) 23915 (67.4%) 119190 (78.1%) 3052102 (85.4%)
Financial Security
   Missing 533114 55515 10021 52988 1766 2865 8459 31477 696204
   Often True 1810315 (61.0%) 56604 (35.2%) 12237 (39.2%) 75430 (51.8%) 269 (9.7%) 3027 (36.1%) 17547 (49.3%) 53128 (35.0%) 2028557 (57.9%)
   Sometimes True 1010346 (34.0%) 76979 (47.9%) 13909 (44.6%) 61889 (42.5%) 2496 (90.3%) 4096 (48.9%) 14891 (41.8%) 80114 (52.8%) 1264720 (36.1%)
   Never True 148029 (5.0%) 27095 (16.9%) 5040 (16.2%) 8354 (5.7%) 0 (0.0%) 1259 (15.0%) 3157 (8.9%) 18429 (12.2%) 211363 (6.0%)
Within the last 30 days, how often have you felt stress?
   Missing 497774 51341 10385 43751 1766 2236 7748 28442 643441
   None of the time 1399472 (46.6%) 73182 (44.4%) 11356 (36.8%) 65660 (42.4%) 557 (20.1%) 2978 (33.0%) 15132 (41.7%) 66044 (42.7%) 1634380 (45.9%)
   A little of the time 894627 (29.8%) 36479 (22.1%) 11250 (36.5%) 46058 (29.7%) 287 (10.4%) 3475 (38.6%) 7780 (21.4%) 39995 (25.9%) 1039951 (29.2%)
   Some of the time 465804 (15.5%) 27345 (16.6%) 3656 (11.9%) 27003 (17.4%) 1270 (45.9%) 797 (8.8%) 6051 (16.7%) 36738 (23.7%) 568665 (16.0%)
   Most of the time 173489 (5.8%) 15650 (9.5%) 2301 (7.5%) 9656 (6.2%) 651 (23.5%) 515 (5.7%) 3566 (9.8%) 7912 (5.1%) 213740 (6.0%)
   All of the time 70638 (2.4%) 12196 (7.4%) 2260 (7.3%) 6531 (4.2%) 0 (0.0%) 1247 (13.8%) 3777 (10.4%) 4018 (2.6%) 100667 (2.8%)
General Health
   Missing 4944 834 59 0 0 7 0 360 6205
   Excellent 667712 (19.1%) 51150 (23.8%) 7218 (17.5%) 42893 (21.6%) 1310 (28.9%) 2136 (19.0%) 3584 (8.1%) 34129 (18.7%) 810132 (19.3%)
   Very Good 1350959 (38.6%) 46697 (21.7%) 8684 (21.1%) 57317 (28.9%) 857 (18.9%) 1053 (9.4%) 11390 (25.9%) 31829 (17.4%) 1508787 (36.0%)
   Good 1077042 (30.8%) 80654 (37.5%) 14824 (36.0%) 77715 (39.1%) 2229 (49.2%) 6074 (54.0%) 21186 (48.1%) 68173 (37.3%) 1347898 (32.1%)
   Fair 302942 (8.7%) 28064 (13.0%) 7366 (17.9%) 19066 (9.6%) 135 (3.0%) 1440 (12.8%) 5031 (11.4%) 40650 (22.2%) 404694 (9.6%)
   Poor 98205 (2.8%) 8792 (4.1%) 3055 (7.4%) 1670 (0.8%) 0 (0.0%) 538 (4.8%) 2863 (6.5%) 8006 (4.4%) 123130 (2.9%)
How many days during the past 30 days was your physical health not good?
   0 2316184 (67.1%) 157275 (73.4%) 24611 (61.0%) 135250 (69.4%) 3864 (85.3%) 7870 (70.0%) 26134 (61.2%) 137350 (77.0%) 2808539 (67.8%)
   1 705480 (20.4%) 26773 (12.5%) 6268 (15.5%) 40332 (20.7%) 278 (6.1%) 2482 (22.1%) 10892 (25.5%) 20228 (11.3%) 812733 (19.6%)
   2 112996 (3.3%) 10435 (4.9%) 2046 (5.1%) 7005 (3.6%) 0 (0.0%) 74 (0.7%) 874 (2.0%) 3391 (1.9%) 136822 (3.3%)
   3 110759 (3.2%) 7825 (3.7%) 3826 (9.5%) 5151 (2.6%) 389 (8.6%) 31 (0.3%) 1382 (3.2%) 6505 (3.6%) 135869 (3.3%)
   4 29828 (0.9%) 2098 (1.0%) 752 (1.9%) 2381 (1.2%) 0 (0.0%) 0 (0.0%) 340 (0.8%) 1353 (0.8%) 36751 (0.9%)
   5 177793 (5.1%) 9934 (4.6%) 2848 (7.1%) 4876 (2.5%) 0 (0.0%) 790 (7.0%) 3092 (7.2%) 9517 (5.3%) 208850 (5.0%)
   Missing 48764 1852 856 3666 0 0 1340 4803 61282
How many days during the past 30 days was your mental health not good?
   0 2337776 (67.7%) 145976 (68.2%) 25447 (61.8%) 134536 (69.4%) 2747 (60.6%) 7433 (66.1%) 23665 (54.4%) 128874 (71.6%) 2806454 (67.7%)
   1 666528 (19.3%) 26256 (12.3%) 6182 (15.0%) 36830 (19.0%) 1040 (22.9%) 2244 (20.0%) 7837 (18.0%) 21344 (11.9%) 768261 (18.5%)
   2 154482 (4.5%) 12900 (6.0%) 1265 (3.1%) 9749 (5.0%) 77 (1.7%) 773 (6.9%) 2594 (6.0%) 10305 (5.7%) 192146 (4.6%)
   3 152568 (4.4%) 11891 (5.6%) 5401 (13.1%) 6670 (3.4%) 667 (14.7%) 113 (1.0%) 3872 (8.9%) 8016 (4.5%) 189198 (4.6%)
   4 26714 (0.8%) 3243 (1.5%) 945 (2.3%) 4187 (2.2%) 0 (0.0%) 0 (0.0%) 660 (1.5%) 1404 (0.8%) 37153 (0.9%)
   5 116866 (3.4%) 13695 (6.4%) 1926 (4.7%) 1837 (0.9%) 0 (0.0%) 685 (6.1%) 4845 (11.1%) 9953 (5.5%) 149807 (3.6%)
   Missing 46869 2232 41 4852 0 0 581 3250 57825
Poor health days
   0 1034161 (60.2%) 43728 (48.3%) 13131 (53.6%) 43701 (50.3%) 568 (31.8%) 3944 (64.4%) 14072 (57.7%) 39641 (55.4%) 1192945 (58.9%)
   1 398138 (23.2%) 21603 (23.9%) 5214 (21.3%) 23768 (27.4%) 1217 (68.2%) 1062 (17.3%) 5176 (21.2%) 16226 (22.7%) 472404 (23.3%)
   2 83986 (4.9%) 7650 (8.4%) 2377 (9.7%) 7705 (8.9%) 0 (0.0%) 38 (0.6%) 1437 (5.9%) 5226 (7.3%) 108419 (5.4%)
   3 96104 (5.6%) 7954 (8.8%) 1690 (6.9%) 10574 (12.2%) 0 (0.0%) 681 (11.1%) 1518 (6.2%) 5222 (7.3%) 123743 (6.1%)
   4 18279 (1.1%) 976 (1.1%) 975 (4.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 712 (2.9%) 454 (0.6%) 21396 (1.1%)
   5 87180 (5.1%) 8658 (9.6%) 1119 (4.6%) 1122 (1.3%) 0 (0.0%) 400 (6.5%) 1468 (6.0%) 4822 (6.7%) 104767 (5.2%)
   Missing 1783956 125624 16702 111790 2747 5123 19671 111558 2177169
Do you smoke cigarettes every day, some days, or not at all?
   Missing 2050881 162422 16938 168026 3097 6068 26072 125699 2559203
   Every day 329568 (22.7%) 23436 (43.6%) 8987 (37.0%) 9275 (30.3%) 135 (9.4%) 2482 (47.9%) 6335 (35.2%) 13835 (24.1%) 394053 (24.0%)
   Some days 143534 (9.9%) 14988 (27.9%) 5593 (23.0%) 6320 (20.6%) 0 (0.0%) 0 (0.0%) 1677 (9.3%) 13391 (23.3%) 185502 (11.3%)
   Not at all 977820 (67.4%) 15347 (28.5%) 9689 (39.9%) 15040 (49.1%) 1300 (90.6%) 2698 (52.1%) 9970 (55.4%) 30223 (52.6%) 1062087 (64.7%)
Do you use vaping products every day, some days, or not at all?
   Missing 2891422 180511 30107 165823 3574 8366 30303 153899 3464005
   Every day 44960 (7.4%) 1231 (3.4%) 643 (5.8%) 2381 (7.2%) 0 (0.0%) 0 (0.0%) 381 (2.8%) 1101 (3.8%) 50696 (6.9%)
   Some days 76843 (12.6%) 6301 (17.7%) 2620 (23.6%) 4891 (14.9%) 0 (0.0%) 0 (0.0%) 955 (6.9%) 4312 (14.7%) 95922 (13.0%)
   Not at all 488579 (80.0%) 28151 (78.9%) 7838 (70.6%) 25566 (77.9%) 958 (100.0%) 2882 (100.0%) 12414 (90.3%) 23835 (81.5%) 590222 (80.1%)
(Ever told) you had a stroke.
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 6189 0 562 644 0 140 0 1267 8801
(Ever told) you had angina or coronary heart disease?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 20810 212 191 2930 0 140 118 2161 26562
(Ever told) you have diabetes
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 2915 212 478 0 0 349 0 210 4165
(Ever told) you that you have a depressive disorder?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 12463 834 100 2215 0 401 453 1486 17952
(Ever told) you have some form of arthritis?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 1) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 12485 436 509 1635 0 494 118 1603 17280
(Ever told) you have COPD, emphysema or chronic bronchitis?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 10938 0 342 2971 0 719 245 860 16075
Are you deaf or do you have serious difficulty hearing?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 69348 10161 2912 10096 821 423 1753 5368 100882
Are you blind or do you have serious difficulty seeing, even when wearing glasses?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 74961 10488 3156 11550 821 423 1753 5581 108732
Because of a physical, mental, or emotional condition, do you have serious difficulty concentrating, remembering, or making decisions?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 83761 12953 3309 10462 821 423 2266 6903 120897
Do you have serious difficulty walking or climbing stairs?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 81916 16366 2807 12104 821 686 1753 6999 123450
Do you have difficulty dressing or bathing?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 83816 13803 2883 12788 821 686 1753 7836 124385
Because of a physical, mental, or emotional condition, do you have difficulty doing errands alone?
   Mean (SD) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0) 0 (0)
   Median (Q1, Q3) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0) 0 (0, 0)
   Min - Max 0 - 1 0 - 1 0 - 1 0 - 1 0 - 0 0 - 1 0 - 1 0 - 1 0 - 1
   Missing 93344 15097 2940 14028 821 686 2207 7439 136562
X_LLCPWT
   Mean (SD) 383 (276) 660 (369) 375 (332) 905 (520) 465 (223) 365 (216) 421 (283) 429 (253) 425 (321)
   Median (Q1, Q3) 313 (194, 492) 556 (385, 889) 268 (163, 475) 753 (533, 1134) 500 (287, 651) 342 (182, 526) 343 (220, 531) 377 (231, 552) 340 (208, 538)
   Min - Max 2 - 2296 4 - 1857 4 - 1434 4 - 2589 70 - 770 3 - 765 3 - 1315 4 - 1256 2 - 2589
   Missing 0 0 0 0 0 0 0 0 0

Weighted tables

SLEPTIM1-

  • On average, how many hours of sleep do you get per night?
    • Less than 7 hours
    • 7-9 hours
    • Greater than 9 hours
stargazer(data.frame(prop.table(svytable(~SLEPTIM1+X_RACE,design= des),
                      margin=2)), summary = FALSE,
          title="Descriptive Statistics",
          type = "html", digits= 3)
Descriptive Statistics
SLEPTIM1 X_RACE Freq
1 Less than 7 hours White only, non-Hispanic 0.285
2 7-9 hours White only, non-Hispanic 0.692
3 Greater than 9 hours White only, non-Hispanic 0.023
4 Less than 7 hours Black only, non-Hispanic 0.436
5 7-9 hours Black only, non-Hispanic 0.532
6 Greater than 9 hours Black only, non-Hispanic 0.032
7 Less than 7 hours American Indian or Alaskan Native Only, non-Hispanic 0.310
8 7-9 hours American Indian or Alaskan Native Only, non-Hispanic 0.602
9 Greater than 9 hours American Indian or Alaskan Native Only, non-Hispanic 0.088
10 Less than 7 hours Asian only, non-Hispanic 0.294
11 7-9 hours Asian only, non-Hispanic 0.669
12 Greater than 9 hours Asian only, non-Hispanic 0.037
13 Less than 7 hours Native Hawaiian or other Pacific Islander only, non-Hispanic 0.239
14 7-9 hours Native Hawaiian or other Pacific Islander only, non-Hispanic 0.761
15 Greater than 9 hours Native Hawaiian or other Pacific Islander only, non-Hispanic 0
16 Less than 7 hours Other race only, non-Hispanic 0.474
17 7-9 hours Other race only, non-Hispanic 0.521
18 Greater than 9 hours Other race only, non-Hispanic 0.005
19 Less than 7 hours Multiracial, non-Hispanic 0.411
20 7-9 hours Multiracial, non-Hispanic 0.542
21 Greater than 9 hours Multiracial, non-Hispanic 0.047
22 Less than 7 hours Hispanic 0.266
23 7-9 hours Hispanic 0.665
24 Greater than 9 hours Hispanic 0.069
stargazer(svyby(formula= ~SLEPTIM1, by = ~X_RACE, 
                design=des,FUN =svymean,na.rm=T),
          title="Descriptive Statistics",
          summary = F, type="html",digits = 2)
Descriptive Statistics
X_RACE SLEPTIM1Less than 7 hours SLEPTIM17-9 hours SLEPTIM1Greater than 9 hours se.SLEPTIM1Less than 7 hours se.SLEPTIM17-9 hours se.SLEPTIM1Greater than 9 hours
White only, non-Hispanic White only, non-Hispanic 0.29 0.69 0.02 0.01 0.01 0.002
Black only, non-Hispanic Black only, non-Hispanic 0.44 0.53 0.03 0.03 0.03 0.01
American Indian or Alaskan Native Only, non-Hispanic American Indian or Alaskan Native Only, non-Hispanic 0.31 0.60 0.09 0.05 0.06 0.05
Asian only, non-Hispanic Asian only, non-Hispanic 0.29 0.67 0.04 0.04 0.04 0.02
Native Hawaiian or other Pacific Islander only, non-Hispanic Native Hawaiian or other Pacific Islander only, non-Hispanic 0.24 0.76 0 0.18 0.18 0
Other race only, non-Hispanic Other race only, non-Hispanic 0.47 0.52 0.005 0.11 0.10 0.005
Multiracial, non-Hispanic Multiracial, non-Hispanic 0.41 0.54 0.05 0.05 0.05 0.02
Hispanic Hispanic 0.27 0.67 0.07 0.02 0.02 0.01

ADSLEEP

  • Over the last 2 weeks, how many days have you had trouble falling asleep or sleeping too much??

    • 0- 6 days
    • 7 or greater
stargazer(data.frame(prop.table(svytable(~ADSLEEP_B+X_RACE,design= des),
                      margin=2)),title="Descriptive Statistics",
                      summary = FALSE,type = "html", digits= 3)
Descriptive Statistics
ADSLEEP_B X_RACE Freq
1 0 White only, non-Hispanic 0.182
2 1 White only, non-Hispanic 0.818
3 0 Black only, non-Hispanic 0.180
4 1 Black only, non-Hispanic 0.820
5 0 American Indian or Alaskan Native Only, non-Hispanic 0.236
6 1 American Indian or Alaskan Native Only, non-Hispanic 0.764
7 0 Asian only, non-Hispanic 0.102
8 1 Asian only, non-Hispanic 0.898
9 0 Native Hawaiian or other Pacific Islander only, non-Hispanic 0.451
10 1 Native Hawaiian or other Pacific Islander only, non-Hispanic 0.549
11 0 Other race only, non-Hispanic 0.303
12 1 Other race only, non-Hispanic 0.697
13 0 Multiracial, non-Hispanic 0.259
14 1 Multiracial, non-Hispanic 0.741
15 0 Hispanic 0.159
16 1 Hispanic 0.841
stargazer(svyby(formula= ~ADSLEEP_B, by = ~X_RACE, 
                design=des,FUN =svymean,na.rm=T),
         title="Descriptive Statistics", 
         summary = F, type="html",digits = 2)
Descriptive Statistics
X_RACE ADSLEEP_B se
White only, non-Hispanic White only, non-Hispanic 0.82 0.004
Black only, non-Hispanic Black only, non-Hispanic 0.82 0.02
American Indian or Alaskan Native Only, non-Hispanic American Indian or Alaskan Native Only, non-Hispanic 0.76 0.04
Asian only, non-Hispanic Asian only, non-Hispanic 0.90 0.02
Native Hawaiian or other Pacific Islander only, non-Hispanic Native Hawaiian or other Pacific Islander only, non-Hispanic 0.55 0.21
Other race only, non-Hispanic Other race only, non-Hispanic 0.70 0.11
Multiracial, non-Hispanic Multiracial, non-Hispanic 0.74 0.05
Hispanic Hispanic 0.84 0.02

Regression

All

ADSLEEP- Difficulty sleeping past 14 days

#Function to save odds ratio from each variable
or_fun <- function(y) {
or_table <- exp(cbind(OR = coef(or), confint(or)))[2, ]
or_table$hv <- c(y)
unlist(or_table)
as.data.frame(or_table)

}

#Binomial logistic regression for each variable
or<-svyglm(ADSLEEP~SEX, family=quasibinomial,design=svydes)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat
or <- svyglm(ADSLEEP~ MARITAL, family = quasibinomial, design = svydes)
b <- or_fun("MARITAL")

or <- svyglm(ADSLEEP~ EDUCA, family = quasibinomial, design = svydes)
c <- or_fun("EDUCA")

or <- svyglm(ADSLEEP~ EMPLOY1, family = quasibinomial, design = svydes)
d <- or_fun("EMPLOY1")

or <- svyglm(ADSLEEP~ INCOME2, family = quasibinomial, design = svydes)
e <- or_fun("INCOME2")

or <- svyglm(ADSLEEP~ X_BMI5CAT, family = quasibinomial, design = svydes)
f <- or_fun("X_BMI5CAT")

or <- svyglm(ADSLEEP~ X_RACE, family = quasibinomial, design = svydes)
g <- or_fun("X_RACE")

or <- svyglm(ADSLEEP~ X_AGEG5YR, family = quasibinomial, design = svydes)
h <- or_fun("X_AGEG5YR")

or <- svyglm(ADSLEEP~ CHILDREN, family = quasibinomial, design = svydes)
i <- or_fun("CHILDREN")

or <- svyglm(ADSLEEP~ SDHBILLS, family = quasibinomial, design = svydes)
j <- or_fun("SDHBILLS")

or <- svyglm(ADSLEEP~ HOWSAFE1, family = quasibinomial, design = svydes)
k <- or_fun("HOWSAFE1")

or <- svyglm(ADSLEEP~ SDHFOOD, family = quasibinomial, design = svydes)
l <- or_fun("SDHFOOD")

or <- svyglm(ADSLEEP~ SDHMEALS, family = quasibinomial, design = svydes)
m <- or_fun("SDHMEALS")

or <- svyglm(ADSLEEP~ SDHMONEY, family = quasibinomial, design = svydes)
n <- or_fun("SDHMONEY")

or <- svyglm(ADSLEEP~ SDHSTRES, family = quasibinomial, design = svydes)
o <- or_fun("SDHSTRES")

or <- svyglm(ADSLEEP~ GENHLTH, family = quasibinomial, design = svydes)
p <- or_fun("GENHLTH")

or <- svyglm(ADSLEEP~ PHYSHLTH, family = quasibinomial, design = svydes)
q <- or_fun("PHYSHLTH")

or <- svyglm(ADSLEEP~ MENTHLTH, family = quasibinomial, design = svydes)
r <- or_fun("MENTHLTH")

or <- svyglm(ADSLEEP~ POORHLTH, family = quasibinomial, design = svydes)
s <- or_fun("POORHLTH")

or <- svyglm(ADSLEEP~ SMOKDAY2, family = quasibinomial, design = svydes)
t <- or_fun("SMOKDAY2")

or <- svyglm(ADSLEEP~ ECIGNOW, family = quasibinomial, design = svydes)
u <- or_fun("ECIGNOW")

or <- svyglm(ADSLEEP~ CVDSTRK3, family = quasibinomial, design = svydes)
v <- or_fun("CVDSTRK3")

or <- svyglm(ADSLEEP~ CVDCRHD4, family = quasibinomial, design = svydes)
w <- or_fun("CVDCRHD4")

or <- svyglm(ADSLEEP~ DIABETE3, family = quasibinomial, design = svydes)
x <- or_fun("DIABETE3")

or <- svyglm(ADSLEEP~ ADDEPEV2, family = quasibinomial, design = svydes)
y <- or_fun("ADDEPEV2")

or <- svyglm(ADSLEEP~ HAVARTH3, family = quasibinomial, design = svydes)
z <- or_fun("HAVARTH3")

or <- svyglm(ADSLEEP~ CHCCOPD1, family = quasibinomial, design = svydes)
aa <- or_fun("CHCCOPD1")

or <- svyglm(ADSLEEP~ DEAF, family = quasibinomial, design = svydes)
bb <- or_fun("DEAF")

or <- svyglm(ADSLEEP~ BLIND, family = quasibinomial, design = svydes)
cc <- or_fun("BLIND")

or <- svyglm(ADSLEEP~ DECIDE, family = quasibinomial, design = svydes)
dd <- or_fun("DECIDE")

or <- svyglm(ADSLEEP~ DIFFWALK, family = quasibinomial, design = svydes)
ee <- or_fun("DIFFWALK")

or <- svyglm(ADSLEEP~ DIFFDRES, family = quasibinomial, design = svydes)
ff <- or_fun("DIFFDRES")

or <- svyglm(ADSLEEP~ DIFFALON, family = quasibinomial, design = svydes)
gg <- or_fun("DIFFALON")


# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, g, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 + X_BMI5CAT
              + X_RACE + X_AGEG5YR + CHILDREN  + SDHBILLS + HOWSAFE1 + SDHFOOD + 
                SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + MENTHLTH + 
                POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 +  CVDCRHD4 + DIABETE3 + 
                ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + DECIDE + 
                DIFFWALK + DIFFDRES + DIFFALON, family = quasibinomial, 
              design = svydes)

summary(alr)
## 
## Call:
## svyglm(formula = ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_RACE + X_AGEG5YR + CHILDREN + SDHBILLS + 
##     HOWSAFE1 + SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + 
##     PHYSHLTH + MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + 
##     CVDCRHD4 + DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + 
##     BLIND + DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydes, 
##     family = quasibinomial)
## 
## Survey design:
## svydesign(id = ~X_PSU, strata = ~X_STSTR, weights = ~X_LLCPWT, 
##     data = brfss2017B, nest = T)
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.22876    0.20263   6.064 1.40e-09 ***
## SEXref        0.23258    0.08048   2.890 0.003866 ** 
## MARITALref   -0.01702    0.08055  -0.211 0.832637    
## EDUCAref     -0.11168    0.08792  -1.270 0.204042    
## EMPLOY1ref   -0.09371    0.08488  -1.104 0.269623    
## INCOME2ref    0.05052    0.11069   0.456 0.648123    
## X_BMI5CATref  0.21380    0.08921   2.397 0.016576 *  
## X_RACEref    -0.26406    0.12051  -2.191 0.028470 *  
## X_AGEG5YRref -0.05044    0.12524  -0.403 0.687161    
## CHILDRENref  -0.12839    0.09052  -1.418 0.156107    
## SDHBILLSref  -0.33833    0.14633  -2.312 0.020804 *  
## HOWSAFE1ref   0.07706    0.19780   0.390 0.696860    
## SDHFOODref   -0.04931    0.14162  -0.348 0.727680    
## SDHMEALSref  -0.22102    0.12372  -1.787 0.074061 .  
## SDHMONEYref   0.03728    0.08751   0.426 0.670134    
## SDHSTRESref  -1.19604    0.11196 -10.682  < 2e-16 ***
## GENHLTHref   -0.37895    0.10304  -3.678 0.000237 ***
## PHYSHLTHref   0.41555    0.10389   4.000 6.40e-05 ***
## MENTHLTHref   0.32346    0.10505   3.079 0.002085 ** 
## POORHLTHref   0.16705    0.12399   1.347 0.177940    
## SMOKDAY2ref  -0.11691    0.11106  -1.053 0.292546    
## ECIGNOWref   -0.04889    0.19157  -0.255 0.798591    
## CVDSTRK3ref   0.21287    0.20329   1.047 0.295079    
## CVDCRHD4ref   0.20579    0.16232   1.268 0.204908    
## DIABETE3ref  -0.02922    0.11977  -0.244 0.807242    
## ADDEPEV2ref  -0.40113    0.08886  -4.514 6.47e-06 ***
## HAVARTH3ref  -0.21351    0.08566  -2.492 0.012709 *  
## CHCCOPD1ref  -0.01844    0.14730  -0.125 0.900364    
## DEAFref      -0.11244    0.13053  -0.861 0.389074    
## BLINDref     -0.13190    0.17407  -0.758 0.448621    
## DECIDEref    -0.42124    0.11336  -3.716 0.000204 ***
## DIFFWALKref  -0.07368    0.11632  -0.633 0.526469    
## DIFFDRESref   0.02556    0.18117   0.141 0.887824    
## DIFFALONref  -0.18098    0.14857  -1.218 0.223232    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 1.008297)
## 
## Number of Fisher Scoring iterations: 4
confint(alr)
##                    2.5 %      97.5 %
## (Intercept)   0.83162547  1.62590232
## SEXref        0.07483836  0.39032102
## MARITALref   -0.17489396  0.14084959
## EDUCAref     -0.28399424  0.06063963
## EMPLOY1ref   -0.26008293  0.07265610
## INCOME2ref   -0.16642450  0.26745653
## X_BMI5CATref  0.03894897  0.38864900
## X_RACEref    -0.50025534 -0.02786605
## X_AGEG5YRref -0.29590750  0.19503090
## CHILDRENref  -0.30579702  0.04901603
## SDHBILLSref  -0.62514070 -0.05152191
## HOWSAFE1ref  -0.31062481  0.46474321
## SDHFOODref   -0.32687704  0.22824799
## SDHMEALSref  -0.46350179  0.02146010
## SDHMONEYref  -0.13424074  0.20879734
## SDHSTRESref  -1.41548215 -0.97659071
## GENHLTHref   -0.58089593 -0.17699937
## PHYSHLTHref   0.21193280  0.61915824
## MENTHLTHref   0.11755960  0.52935755
## POORHLTHref  -0.07597198  0.41007866
## SMOKDAY2ref  -0.33458955  0.10077158
## ECIGNOWref   -0.42436541  0.32659313
## CVDSTRK3ref  -0.18557174  0.61131249
## CVDCRHD4ref  -0.11234688  0.52391735
## DIABETE3ref  -0.26397792  0.20552911
## ADDEPEV2ref  -0.57529862 -0.22696248
## HAVARTH3ref  -0.38139947 -0.04561521
## CHCCOPD1ref  -0.30714755  0.27026162
## DEAFref      -0.36828013  0.14340719
## BLINDref     -0.47307946  0.20927028
## DECIDEref    -0.64342757 -0.19905690
## DIFFWALKref  -0.30167731  0.15430820
## DIFFDRESref  -0.32953171  0.38064459
## DIFFALONref  -0.47217812  0.11022394
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    3.4170032    1.2618510    0.9831219    0.8943328    0.9105437    1.0518137 
## X_BMI5CATref    X_RACEref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref 
##    1.2383737    0.7679269    0.9508126    0.8795099    0.7129590    1.0801060 
##   SDHFOODref  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref 
##    0.9518817    0.8017000    1.0379819    0.3023904    0.6845815    1.5151971 
##  MENTHLTHref  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref 
##    1.3818989    1.1818173    0.8896662    0.9522896    1.2372243    1.2284893 
##  DIABETE3ref  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref 
##    0.9711985    0.6695626    0.8077462    0.9817261    0.8936541    0.8764246 
##    DECIDEref  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    0.6562311    0.9289647    1.0258858    0.8344545
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR     2.5 %    97.5 %
## (Intercept)  3.4170032 2.2970495 5.0830035
## SEXref       1.2618510 1.0777099 1.4774550
## MARITALref   0.9831219 0.8395460 1.1512515
## EDUCAref     0.8943328 0.7527710 1.0625159
## EMPLOY1ref   0.9105437 0.7709876 1.0753607
## INCOME2ref   1.0518137 0.8466867 1.3066368
## X_BMI5CATref 1.2383737 1.0397174 1.4749867
## X_RACEref    0.7679269 0.6063758 0.9725186
## X_AGEG5YRref 0.9508126 0.7438562 1.2153485
## CHILDRENref  0.8795099 0.7365361 1.0502372
## SDHBILLSref  0.7129590 0.5351861 0.9497828
## HOWSAFE1ref  1.0801060 0.7329888 1.5916054
## SDHFOODref   0.9518817 0.7211724 1.2563969
## SDHMEALSref  0.8017000 0.6290769 1.0216920
## SDHMONEYref  1.0379819 0.8743795 1.2321953
## SDHSTRESref  0.3023904 0.2428085 0.3765928
## GENHLTHref   0.6845815 0.5593970 0.8377803
## PHYSHLTHref  1.5151971 1.2360648 1.8573639
## MENTHLTHref  1.3818989 1.1247487 1.6978412
## POORHLTHref  1.1818173 0.9268422 1.5069363
## SMOKDAY2ref  0.8896662 0.7156318 1.1060240
## ECIGNOWref   0.9522896 0.6541848 1.3862373
## CVDSTRK3ref  1.2372243 0.8306292 1.8428485
## CVDCRHD4ref  1.2284893 0.8937342 1.6886297
## DIABETE3ref  0.9711985 0.7679905 1.2281747
## ADDEPEV2ref  0.6695626 0.5625369 0.7969507
## HAVARTH3ref  0.8077462 0.6829050 0.9554095
## CHCCOPD1ref  0.9817261 0.7355421 1.3103072
## DEAFref      0.8936541 0.6919233 1.1541997
## BLINDref     0.8764246 0.6230806 1.2327781
## DECIDEref    0.6562311 0.5254882 0.8195033
## DIFFWALKref  0.9289647 0.7395767 1.1668505
## DIFFDRESref  1.0258858 0.7192605 1.4632275
## DIFFALONref  0.8344545 0.6236424 1.1165281
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR     2.5 %    97.5 %
## SEXref       1.2618510 1.0777099 1.4774550
## MARITALref   0.9831219 0.8395460 1.1512515
## EDUCAref     0.8943328 0.7527710 1.0625159
## EMPLOY1ref   0.9105437 0.7709876 1.0753607
## INCOME2ref   1.0518137 0.8466867 1.3066368
## X_BMI5CATref 1.2383737 1.0397174 1.4749867
## X_RACEref    0.7679269 0.6063758 0.9725186
## X_AGEG5YRref 0.9508126 0.7438562 1.2153485
## CHILDRENref  0.8795099 0.7365361 1.0502372
## SDHBILLSref  0.7129590 0.5351861 0.9497828
## HOWSAFE1ref  1.0801060 0.7329888 1.5916054
## SDHFOODref   0.9518817 0.7211724 1.2563969
## SDHMEALSref  0.8017000 0.6290769 1.0216920
## SDHMONEYref  1.0379819 0.8743795 1.2321953
## SDHSTRESref  0.3023904 0.2428085 0.3765928
## GENHLTHref   0.6845815 0.5593970 0.8377803
## PHYSHLTHref  1.5151971 1.2360648 1.8573639
## MENTHLTHref  1.3818989 1.1247487 1.6978412
## POORHLTHref  1.1818173 0.9268422 1.5069363
## SMOKDAY2ref  0.8896662 0.7156318 1.1060240
## ECIGNOWref   0.9522896 0.6541848 1.3862373
## CVDSTRK3ref  1.2372243 0.8306292 1.8428485
## CVDCRHD4ref  1.2284893 0.8937342 1.6886297
## DIABETE3ref  0.9711985 0.7679905 1.2281747
## ADDEPEV2ref  0.6695626 0.5625369 0.7969507
## HAVARTH3ref  0.8077462 0.6829050 0.9554095
## CHCCOPD1ref  0.9817261 0.7355421 1.3103072
## DEAFref      0.8936541 0.6919233 1.1541997
## BLINDref     0.8764246 0.6230806 1.2327781
## DECIDEref    0.6562311 0.5254882 0.8195033
## DIFFWALKref  0.9289647 0.7395767 1.1668505
## DIFFDRESref  1.0258858 0.7192605 1.4632275
## DIFFALONref  0.8344545 0.6236424 1.1165281
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 1.51 1.36 1.69 SEX 1.26 1.08 1.48
MARITALref 1.53 1.37 1.70 MARITAL 0.98 0.84 1.15
EDUCAref 0.89 0.79 1.00 EDUCA 0.89 0.75 1.06
EMPLOY1ref 1.26 1.13 1.40 EMPLOY1 0.91 0.77 1.08
INCOME2ref 0.97 0.83 1.14 INCOME2 1.05 0.85 1.31
X_BMI5CATref 1.27 1.12 1.43 X_BMI5CAT 1.24 1.04 1.47
X_RACEref 1.00 0.85 1.17 X_RACE 0.77 0.61 0.97
X_AGEG5YRref 0.93 0.79 1.10 X_AGEG5YR 0.95 0.74 1.22
CHILDRENref 0.85 0.75 0.96 CHILDREN 0.88 0.74 1.05
SDHBILLSref 0.29 0.24 0.34 SDHBILLS 0.71 0.54 0.95
HOWSAFE1ref 0.40 0.31 0.52 HOWSAFE1 1.08 0.73 1.59
SDHFOODref 0.36 0.31 0.42 SDHFOOD 0.95 0.72 1.26
SDHMEALSref 0.39 0.34 0.45 SDHMEALS 0.80 0.63 1.02
SDHMONEYref 0.55 0.49 0.61 SDHMONEY 1.04 0.87 1.23
SDHSTRESref 0.13 0.11 0.16 SDHSTRES 0.30 0.24 0.38
GENHLTHref 0.29 0.25 0.33 GENHLTH 0.68 0.56 0.84
PHYSHLTHref 3.89 3.40 4.45 PHYSHLTH 1.52 1.24 1.86
MENTHLTHref 4.82 4.15 5.60 MENTHLTH 1.38 1.12 1.70
POORHLTHref 3.48 2.92 4.14 POORHLTH 1.18 0.93 1.51
SMOKDAY2ref 0.51 0.44 0.58 SMOKDAY2 0.89 0.72 1.11
ECIGNOWref 0.57 0.43 0.76 ECIGNOW 0.95 0.65 1.39
CVDSTRK3ref 0.57 0.43 0.75 CVDSTRK3 1.24 0.83 1.84
CVDCRHD4ref 0.68 0.55 0.84 CVDCRHD4 1.23 0.89 1.69
DIABETE3ref 0.73 0.62 0.85 DIABETE3 0.97 0.77 1.23
ADDEPEV2ref 0.29 0.25 0.32 ADDEPEV2 0.67 0.56 0.80
HAVARTH3ref 0.50 0.44 0.55 HAVARTH3 0.81 0.68 0.96
CHCCOPD1ref 0.38 0.31 0.46 CHCCOPD1 0.98 0.74 1.31
DEAFref 0.58 0.49 0.70 DEAF 0.89 0.69 1.15
BLINDref 0.48 0.38 0.60 BLIND 0.88 0.62 1.23
DECIDEref 0.19 0.16 0.22 DECIDE 0.66 0.53 0.82
DIFFWALKref 0.33 0.29 0.38 DIFFWALK 0.93 0.74 1.17
DIFFDRESref 0.22 0.17 0.27 DIFFDRES 1.03 0.72 1.46
DIFFALONref 0.19 0.16 0.23 DIFFALON 0.83 0.62 1.12
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR
ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

#Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#Plot OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

SLEPTIM1- Hours per sleep at night

#Binomial logistic regression for each variable
or<-svyglm(SLEPTIM1~SEX, family=quasibinomial,design=svydes)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat
or <- svyglm(SLEPTIM1~ MARITAL, family = quasibinomial, design = svydes)
b <- or_fun("MARITAL")

or <- svyglm(SLEPTIM1~ EDUCA, family = quasibinomial, design = svydes)
c <- or_fun("EDUCA")

or <- svyglm(SLEPTIM1~ EMPLOY1, family = quasibinomial, design = svydes)
d <- or_fun("EMPLOY1")

or <- svyglm(SLEPTIM1~ INCOME2, family = quasibinomial, design = svydes)
e <- or_fun("INCOME2")

or <- svyglm(SLEPTIM1~ X_BMI5CAT, family = quasibinomial, design = svydes)
f <- or_fun("X_BMI5CAT")

or <- svyglm(SLEPTIM1~ X_RACE, family = quasibinomial, design = svydes)
g <- or_fun("X_RACE")

or <- svyglm(SLEPTIM1~ X_AGEG5YR, family = quasibinomial, design = svydes)
h <- or_fun("X_AGEG5YR")

or <- svyglm(SLEPTIM1~ CHILDREN, family = quasibinomial, design = svydes)
i <- or_fun("CHILDREN")

or <- svyglm(SLEPTIM1~ SDHBILLS, family = quasibinomial, design = svydes)
j <- or_fun("SDHBILLS")

or <- svyglm(SLEPTIM1~ HOWSAFE1, family = quasibinomial, design = svydes)
k <- or_fun("HOWSAFE1")

or <- svyglm(SLEPTIM1~ SDHFOOD, family = quasibinomial, design = svydes)
l <- or_fun("SDHFOOD")

or <- svyglm(SLEPTIM1~ SDHMEALS, family = quasibinomial, design = svydes)
m <- or_fun("SDHMEALS")

or <- svyglm(SLEPTIM1~ SDHMONEY, family = quasibinomial, design = svydes)
n <- or_fun("SDHMONEY")

or <- svyglm(SLEPTIM1~ SDHSTRES, family = quasibinomial, design = svydes)
o <- or_fun("SDHSTRES")

or <- svyglm(SLEPTIM1~ GENHLTH, family = quasibinomial, design = svydes)
p <- or_fun("GENHLTH")

or <- svyglm(SLEPTIM1~ PHYSHLTH, family = quasibinomial, design = svydes)
q <- or_fun("PHYSHLTH")

or <- svyglm(SLEPTIM1~ MENTHLTH, family = quasibinomial, design = svydes)
r <- or_fun("MENTHLTH")

or <- svyglm(SLEPTIM1~ POORHLTH, family = quasibinomial, design = svydes)
s <- or_fun("POORHLTH")

or <- svyglm(SLEPTIM1~ SMOKDAY2, family = quasibinomial, design = svydes)
t <- or_fun("SMOKDAY2")

or <- svyglm(SLEPTIM1~ ECIGNOW, family = quasibinomial, design = svydes)
u <- or_fun("ECIGNOW")

or <- svyglm(SLEPTIM1~ CVDSTRK3, family = quasibinomial, design = svydes)
v <- or_fun("CVDSTRK3")

or <- svyglm(SLEPTIM1~ CVDCRHD4, family = quasibinomial, design = svydes)
w <- or_fun("CVDCRHD4")

or <- svyglm(SLEPTIM1~ DIABETE3, family = quasibinomial, design = svydes)
x <- or_fun("DIABETE3")

or <- svyglm(SLEPTIM1~ ADDEPEV2, family = quasibinomial, design = svydes)
y <- or_fun("ADDEPEV2")

or <- svyglm(SLEPTIM1~ HAVARTH3, family = quasibinomial, design = svydes)
z <- or_fun("HAVARTH3")

or <- svyglm(SLEPTIM1~ CHCCOPD1, family = quasibinomial, design = svydes)
aa <- or_fun("CHCCOPD1")

or <- svyglm(SLEPTIM1~ DEAF, family = quasibinomial, design = svydes)
bb <- or_fun("DEAF")

or <- svyglm(SLEPTIM1~ BLIND, family = quasibinomial, design = svydes)
cc <- or_fun("BLIND")

or <- svyglm(SLEPTIM1~ DECIDE, family = quasibinomial, design = svydes)
dd <- or_fun("DECIDE")

or <- svyglm(SLEPTIM1~ DIFFWALK, family = quasibinomial, design = svydes)
ee <- or_fun("DIFFWALK")

or <- svyglm(SLEPTIM1~ DIFFDRES, family = quasibinomial, design = svydes)
ff <- or_fun("DIFFDRES")

or <- svyglm(SLEPTIM1~ DIFFALON, family = quasibinomial, design = svydes)
gg <- or_fun("DIFFALON")


# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, g, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 +
                X_BMI5CAT + X_RACE + X_AGEG5YR + CHILDREN  + SDHBILLS + 
                HOWSAFE1 + SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + 
                PHYSHLTH + MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW +
                CVDSTRK3 +  CVDCRHD4 + DIABETE3 + ADDEPEV2 + HAVARTH3 + 
                CHCCOPD1 + DEAF + BLIND + DECIDE + DIFFWALK + DIFFDRES +
                DIFFALON, family = quasibinomial, design = svydes)

summary(alr)
## 
## Call:
## svyglm(formula = SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_RACE + X_AGEG5YR + CHILDREN + SDHBILLS + 
##     HOWSAFE1 + SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + 
##     PHYSHLTH + MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + 
##     CVDCRHD4 + DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + 
##     BLIND + DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydes, 
##     family = quasibinomial)
## 
## Survey design:
## svydesign(id = ~X_PSU, strata = ~X_STSTR, weights = ~X_LLCPWT, 
##     data = brfss2017B, nest = T)
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -0.630022   0.172344  -3.656 0.000258 ***
## SEXref       -0.077728   0.063435  -1.225 0.220488    
## MARITALref    0.257943   0.063768   4.045 5.28e-05 ***
## EDUCAref     -0.168772   0.072701  -2.321 0.020287 *  
## EMPLOY1ref   -0.163115   0.067362  -2.421 0.015480 *  
## INCOME2ref   -0.114752   0.093423  -1.228 0.219369    
## X_BMI5CATref  0.079891   0.071506   1.117 0.263919    
## X_RACEref     0.404703   0.095466   4.239 2.27e-05 ***
## X_AGEG5YRref -0.317459   0.099133  -3.202 0.001369 ** 
## CHILDRENref   0.418076   0.072892   5.736 1.01e-08 ***
## SDHBILLSref  -0.131381   0.130492  -1.007 0.314056    
## HOWSAFE1ref   0.112011   0.168495   0.665 0.506216    
## SDHFOODref    0.380721   0.135520   2.809 0.004977 ** 
## SDHMEALSref  -0.084301   0.118490  -0.711 0.476821    
## SDHMONEYref   0.426318   0.072351   5.892 3.96e-09 ***
## SDHSTRESref  -0.451402   0.109257  -4.132 3.64e-05 ***
## GENHLTHref   -0.425845   0.088635  -4.804 1.58e-06 ***
## PHYSHLTHref  -0.061632   0.088960  -0.693 0.488449    
## MENTHLTHref   0.257765   0.087544   2.944 0.003245 ** 
## POORHLTHref   0.245183   0.107670   2.277 0.022802 *  
## SMOKDAY2ref  -0.373156   0.089999  -4.146 3.41e-05 ***
## ECIGNOWref    0.175950   0.160832   1.094 0.273989    
## CVDSTRK3ref   0.118320   0.164820   0.718 0.472854    
## CVDCRHD4ref  -0.054346   0.135776  -0.400 0.688971    
## DIABETE3ref  -0.108432   0.097819  -1.108 0.267680    
## ADDEPEV2ref   0.047199   0.074719   0.632 0.527612    
## HAVARTH3ref  -0.181609   0.072468  -2.506 0.012229 *  
## CHCCOPD1ref  -0.262680   0.117140  -2.242 0.024960 *  
## DEAFref      -0.005874   0.109725  -0.054 0.957311    
## BLINDref     -0.256423   0.159788  -1.605 0.108585    
## DECIDEref    -0.237306   0.103165  -2.300 0.021459 *  
## DIFFWALKref   0.206776   0.101710   2.033 0.042086 *  
## DIFFDRESref  -0.249518   0.156452  -1.595 0.110785    
## DIFFALONref  -0.224213   0.133028  -1.685 0.091939 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 1.023553)
## 
## Number of Fisher Scoring iterations: 4
confint(alr)
##                     2.5 %      97.5 %
## (Intercept)  -0.967809080 -0.29223470
## SEXref       -0.202058279  0.04660155
## MARITALref    0.132959785  0.38292703
## EDUCAref     -0.311262106 -0.02628115
## EMPLOY1ref   -0.295142236 -0.03108843
## INCOME2ref   -0.297857895  0.06835400
## X_BMI5CATref -0.060258917  0.22004039
## X_RACEref     0.217592988  0.59181276
## X_AGEG5YRref -0.511757490 -0.12316139
## CHILDRENref   0.275210777  0.56094178
## SDHBILLSref  -0.387141761  0.12437900
## HOWSAFE1ref  -0.218233556  0.44225474
## SDHFOODref    0.115105721  0.64633546
## SDHMEALSref  -0.316537885  0.14793596
## SDHMONEYref   0.284511848  0.56812355
## SDHSTRESref  -0.665541753 -0.23726185
## GENHLTHref   -0.599565688 -0.25212347
## PHYSHLTHref  -0.235989669  0.11272553
## MENTHLTHref   0.086181978  0.42934832
## POORHLTHref   0.034154619  0.45621235
## SMOKDAY2ref  -0.549549451 -0.19676175
## ECIGNOWref   -0.139274978  0.49117438
## CVDSTRK3ref  -0.204720310  0.44136111
## CVDCRHD4ref  -0.320462453  0.21176946
## DIABETE3ref  -0.300154164  0.08328952
## ADDEPEV2ref  -0.099248063  0.19364570
## HAVARTH3ref  -0.323643232 -0.03957411
## CHCCOPD1ref  -0.492270436 -0.03308933
## DEAFref      -0.220930370  0.20918320
## BLINDref     -0.569602037  0.05675655
## DECIDEref    -0.439505292 -0.03510761
## DIFFWALKref   0.007427802  0.40612398
## DIFFDRESref  -0.556157868  0.05712206
## DIFFALONref  -0.484943054  0.03651623
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    0.5325801    0.9252157    1.2942656    0.8447018    0.8494932    0.8915873 
## X_BMI5CATref    X_RACEref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref 
##    1.0831687    1.4988571    0.7279962    1.5190365    0.8768833    1.1185247 
##   SDHFOODref  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref 
##    1.4633387    0.9191546    1.5316073    0.6367350    0.6532179    0.9402288 
##  MENTHLTHref  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref 
##    1.2940349    1.2778558    0.6885581    1.1923781    1.1256047    0.9471039 
##  DIABETE3ref  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref 
##    0.8972396    1.0483304    0.8339276    0.7689880    0.9941436    0.7738148 
##    DECIDEref  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    0.7887495    1.2297070    0.7791763    0.7991446
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR     2.5 %    97.5 %
## (Intercept)  0.5325801 0.3799145 0.7465933
## SEXref       0.9252157 0.8170473 1.0477045
## MARITALref   1.2942656 1.1422041 1.4665710
## EDUCAref     0.8447018 0.7325219 0.9740612
## EMPLOY1ref   0.8494932 0.7444257 0.9693898
## INCOME2ref   0.8915873 0.7424068 1.0707443
## X_BMI5CATref 1.0831687 0.9415207 1.2461271
## X_RACEref    1.4988571 1.2430810 1.8072616
## X_AGEG5YRref 0.7279962 0.5994411 0.8841210
## CHILDRENref  1.5190365 1.3168082 1.7523220
## SDHBILLSref  0.8768833 0.6789948 1.1324450
## HOWSAFE1ref  1.1185247 0.8039377 1.5562121
## SDHFOODref   1.4633387 1.1219920 1.9085341
## SDHMEALSref  0.9191546 0.7286674 1.1594386
## SDHMONEYref  1.5316073 1.3291131 1.7649521
## SDHSTRESref  0.6367350 0.5139950 0.7887847
## GENHLTHref   0.6532179 0.5490500 0.7771488
## PHYSHLTHref  0.9402288 0.7897888 1.1193247
## MENTHLTHref  1.2940349 1.0900047 1.5362561
## POORHLTHref  1.2778558 1.0347446 1.5780854
## SMOKDAY2ref  0.6885581 0.5772098 0.8213863
## ECIGNOWref   1.1923781 0.8699888 1.6342343
## CVDSTRK3ref  1.1256047 0.8148752 1.5548221
## CVDCRHD4ref  0.9471039 0.7258133 1.2358629
## DIABETE3ref  0.8972396 0.7407040 1.0868564
## ADDEPEV2ref  1.0483304 0.9055181 1.2136662
## HAVARTH3ref  0.8339276 0.7235083 0.9611987
## CHCCOPD1ref  0.7689880 0.6112370 0.9674521
## DEAFref      0.9941436 0.8017725 1.2326708
## BLINDref     0.7738148 0.5657505 1.0583981
## DECIDEref    0.7887495 0.6443551 0.9655015
## DIFFWALKref  1.2297070 1.0074555 1.5009886
## DIFFDRESref  0.7791763 0.5734079 1.0587850
## DIFFALONref  0.7991446 0.6157323 1.0371911
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR     2.5 %    97.5 %
## SEXref       0.9252157 0.8170473 1.0477045
## MARITALref   1.2942656 1.1422041 1.4665710
## EDUCAref     0.8447018 0.7325219 0.9740612
## EMPLOY1ref   0.8494932 0.7444257 0.9693898
## INCOME2ref   0.8915873 0.7424068 1.0707443
## X_BMI5CATref 1.0831687 0.9415207 1.2461271
## X_RACEref    1.4988571 1.2430810 1.8072616
## X_AGEG5YRref 0.7279962 0.5994411 0.8841210
## CHILDRENref  1.5190365 1.3168082 1.7523220
## SDHBILLSref  0.8768833 0.6789948 1.1324450
## HOWSAFE1ref  1.1185247 0.8039377 1.5562121
## SDHFOODref   1.4633387 1.1219920 1.9085341
## SDHMEALSref  0.9191546 0.7286674 1.1594386
## SDHMONEYref  1.5316073 1.3291131 1.7649521
## SDHSTRESref  0.6367350 0.5139950 0.7887847
## GENHLTHref   0.6532179 0.5490500 0.7771488
## PHYSHLTHref  0.9402288 0.7897888 1.1193247
## MENTHLTHref  1.2940349 1.0900047 1.5362561
## POORHLTHref  1.2778558 1.0347446 1.5780854
## SMOKDAY2ref  0.6885581 0.5772098 0.8213863
## ECIGNOWref   1.1923781 0.8699888 1.6342343
## CVDSTRK3ref  1.1256047 0.8148752 1.5548221
## CVDCRHD4ref  0.9471039 0.7258133 1.2358629
## DIABETE3ref  0.8972396 0.7407040 1.0868564
## ADDEPEV2ref  1.0483304 0.9055181 1.2136662
## HAVARTH3ref  0.8339276 0.7235083 0.9611987
## CHCCOPD1ref  0.7689880 0.6112370 0.9674521
## DEAFref      0.9941436 0.8017725 1.2326708
## BLINDref     0.7738148 0.5657505 1.0583981
## DECIDEref    0.7887495 0.6443551 0.9655015
## DIFFWALKref  1.2297070 1.0074555 1.5009886
## DIFFDRESref  0.7791763 0.5734079 1.0587850
## DIFFALONref  0.7991446 0.6157323 1.0371911
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 0.86 0.80 0.93 SEX 0.93 0.82 1.05
MARITALref 1.41 1.30 1.53 MARITAL 1.29 1.14 1.47
EDUCAref 0.81 0.74 0.89 EDUCA 0.84 0.73 0.97
EMPLOY1ref 0.88 0.82 0.96 EMPLOY1 0.85 0.74 0.97
INCOME2ref 0.97 0.86 1.10 INCOME2 0.89 0.74 1.07
X_BMI5CATref 1.28 1.16 1.40 X_BMI5CAT 1.08 0.94 1.25
X_RACEref 1.62 1.44 1.82 X_RACE 1.50 1.24 1.81
X_AGEG5YRref 0.83 0.72 0.95 X_AGEG5YR 0.73 0.60 0.88
CHILDRENref 1.32 1.21 1.45 CHILDREN 1.52 1.32 1.75
SDHBILLSref 0.67 0.56 0.80 SDHBILLS 0.88 0.68 1.13
HOWSAFE1ref 0.74 0.57 0.96 HOWSAFE1 1.12 0.80 1.56
SDHFOODref 0.85 0.73 0.98 SDHFOOD 1.46 1.12 1.91
SDHMEALSref 0.85 0.74 0.97 SDHMEALS 0.92 0.73 1.16
SDHMONEYref 1.16 1.06 1.27 SDHMONEY 1.53 1.33 1.76
SDHSTRESref 0.45 0.38 0.53 SDHSTRES 0.64 0.51 0.79
GENHLTHref 0.53 0.47 0.60 GENHLTH 0.65 0.55 0.78
PHYSHLTHref 1.59 1.41 1.80 PHYSHLTH 0.94 0.79 1.12
MENTHLTHref 2.02 1.76 2.31 MENTHLTH 1.29 1.09 1.54
POORHLTHref 1.97 1.68 2.32 POORHLTH 1.28 1.03 1.58
SMOKDAY2ref 0.63 0.56 0.71 SMOKDAY2 0.69 0.58 0.82
ECIGNOWref 0.78 0.62 1.00 ECIGNOW 1.19 0.87 1.63
CVDSTRK3ref 0.85 0.67 1.07 CVDSTRK3 1.13 0.81 1.55
CVDCRHD4ref 0.90 0.75 1.09 CVDCRHD4 0.95 0.73 1.24
DIABETE3ref 0.90 0.79 1.03 DIABETE3 0.90 0.74 1.09
ADDEPEV2ref 0.75 0.68 0.83 ADDEPEV2 1.05 0.91 1.21
HAVARTH3ref 0.89 0.81 0.97 HAVARTH3 0.83 0.72 0.96
CHCCOPD1ref 0.61 0.51 0.72 CHCCOPD1 0.77 0.61 0.97
DEAFref 0.90 0.77 1.05 DEAF 0.99 0.80 1.23
BLINDref 0.63 0.50 0.79 BLIND 0.77 0.57 1.06
DECIDEref 0.51 0.44 0.59 DECIDE 0.79 0.64 0.97
DIFFWALKref 0.77 0.69 0.87 DIFFWALK 1.23 1.01 1.50
DIFFDRESref 0.45 0.36 0.56 DIFFDRES 0.78 0.57 1.06
DIFFALONref 0.47 0.39 0.56 DIFFALON 0.80 0.62 1.04
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR

ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

#Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) +
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

Non-White

ADSLEEP - Difficulty sleeping past 14 days

svydesNW<-subset(svydes,RACE != "White only, non-Hispanic")

#Binomial logistic regression for each variable
or<-svyglm(ADSLEEP~SEX, family=quasibinomial,design=svydesNW)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat
or <- svyglm(ADSLEEP~ MARITAL, family = quasibinomial, design = svydesNW)
b <- or_fun("MARITAL")

or <- svyglm(ADSLEEP~ EDUCA, family = quasibinomial, design = svydesNW)
c <- or_fun("EDUCA")

or <- svyglm(ADSLEEP~ EMPLOY1, family = quasibinomial, design = svydesNW)
d <- or_fun("EMPLOY1")

or <- svyglm(ADSLEEP~ INCOME2, family = quasibinomial, design = svydesNW)
e <- or_fun("INCOME2")

or <- svyglm(ADSLEEP~ X_BMI5CAT, family = quasibinomial, design = svydesNW)
f <- or_fun("X_BMI5CAT")

or <- svyglm(ADSLEEP~ X_AGEG5YR, family = quasibinomial, design = svydesNW)
h <- or_fun("X_AGEG5YR")

or <- svyglm(ADSLEEP~ CHILDREN, family = quasibinomial, design = svydesNW)
i <- or_fun("CHILDREN")

or <- svyglm(ADSLEEP~ SDHBILLS, family = quasibinomial, design = svydesNW)
j <- or_fun("SDHBILLS")

or <- svyglm(ADSLEEP~ HOWSAFE1, family = quasibinomial, design = svydesNW)
k <- or_fun("HOWSAFE1")

or <- svyglm(ADSLEEP~ SDHFOOD, family = quasibinomial, design = svydesNW)
l <- or_fun("SDHFOOD")

or <- svyglm(ADSLEEP~ SDHMEALS, family = quasibinomial, design = svydesNW)
m <- or_fun("SDHMEALS")

or <- svyglm(ADSLEEP~ SDHMONEY, family = quasibinomial, design = svydesNW)
n <- or_fun("SDHMONEY")

or <- svyglm(ADSLEEP~ SDHSTRES, family = quasibinomial, design = svydesNW)
o <- or_fun("SDHSTRES")

or <- svyglm(ADSLEEP~ GENHLTH, family = quasibinomial, design = svydesNW)
p <- or_fun("GENHLTH")

or <- svyglm(ADSLEEP~ PHYSHLTH, family = quasibinomial, design = svydesNW)
q <- or_fun("PHYSHLTH")

or <- svyglm(ADSLEEP~ MENTHLTH, family = quasibinomial, design = svydesNW)
r <- or_fun("MENTHLTH")

or <- svyglm(ADSLEEP~ POORHLTH, family = quasibinomial, design = svydesNW)
s <- or_fun("POORHLTH")

or <- svyglm(ADSLEEP~ SMOKDAY2, family = quasibinomial, design = svydesNW)
t <- or_fun("SMOKDAY2")

or <- svyglm(ADSLEEP~ ECIGNOW, family = quasibinomial, design = svydesNW)
u <- or_fun("ECIGNOW")

or <- svyglm(ADSLEEP~ CVDSTRK3, family = quasibinomial, design = svydesNW)
v <- or_fun("CVDSTRK3")

or <- svyglm(ADSLEEP~ CVDCRHD4, family = quasibinomial, design = svydesNW)
w <- or_fun("CVDCRHD4")

or <- svyglm(ADSLEEP~ DIABETE3, family = quasibinomial, design = svydesNW)
x <- or_fun("DIABETE3")

or <- svyglm(ADSLEEP~ ADDEPEV2, family = quasibinomial, design = svydesNW)
y <- or_fun("ADDEPEV2")

or <- svyglm(ADSLEEP~ HAVARTH3, family = quasibinomial, design = svydesNW)
z <- or_fun("HAVARTH3")

or <- svyglm(ADSLEEP~ CHCCOPD1, family = quasibinomial, design = svydesNW)
aa <- or_fun("CHCCOPD1")

or <- svyglm(ADSLEEP~ DEAF, family = quasibinomial, design = svydesNW)
bb <- or_fun("DEAF")

or <- svyglm(ADSLEEP~ BLIND, family = quasibinomial, design = svydesNW)
cc <- or_fun("BLIND")

or <- svyglm(ADSLEEP~ DECIDE, family = quasibinomial, design = svydesNW)
dd <- or_fun("DECIDE")

or <- svyglm(ADSLEEP~ DIFFWALK, family = quasibinomial, design = svydesNW)
ee <- or_fun("DIFFWALK")

or <- svyglm(ADSLEEP~ DIFFDRES, family = quasibinomial, design = svydesNW)
ff <- or_fun("DIFFDRES")

or <- svyglm(ADSLEEP~ DIFFALON, family = quasibinomial, design = svydesNW)
gg <- or_fun("DIFFALON")


# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR

alr <- svyglm(ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 + X_BMI5CAT
               + X_AGEG5YR + CHILDREN  + SDHBILLS + HOWSAFE1 + SDHFOOD + 
                SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + MENTHLTH + 
                POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 +  CVDCRHD4 + DIABETE3 + 
                ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + DECIDE + 
                DIFFWALK + DIFFDRES + DIFFALON, family = quasibinomial, 
              design = svydesNW)

summary(alr)
## 
## Call:
## svyglm(formula = ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_AGEG5YR + CHILDREN + SDHBILLS + HOWSAFE1 + 
##     SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + 
##     MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + CVDCRHD4 + 
##     DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + 
##     DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydesNW, 
##     family = quasibinomial)
## 
## Survey design:
## subset(svydes, RACE != "White only, non-Hispanic")
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.93935    0.49684   1.891  0.05909 .  
## SEXref        0.70491    0.24019   2.935  0.00345 ** 
## MARITALref   -0.18148    0.27367  -0.663  0.50746    
## EDUCAref      0.42831    0.26966   1.588  0.11266    
## EMPLOY1ref    0.08239    0.26443   0.312  0.75547    
## INCOME2ref    0.03632    0.34778   0.104  0.91684    
## X_BMI5CATref  0.25613    0.28124   0.911  0.36276    
## X_AGEG5YRref  0.13407    0.47878   0.280  0.77954    
## CHILDRENref  -0.49377    0.24819  -1.989  0.04704 *  
## SDHBILLSref  -0.29833    0.33199  -0.899  0.36918    
## HOWSAFE1ref   0.04694    0.34750   0.135  0.89259    
## SDHFOODref    0.16259    0.33896   0.480  0.63161    
## SDHMEALSref  -0.28154    0.32201  -0.874  0.38225    
## SDHMONEYref  -0.42647    0.26906  -1.585  0.11342    
## SDHSTRESref  -1.38205    0.28505  -4.848 1.54e-06 ***
## GENHLTHref   -0.31268    0.28793  -1.086  0.27788    
## PHYSHLTHref   0.39879    0.33059   1.206  0.22812    
## MENTHLTHref   0.05579    0.31683   0.176  0.86029    
## POORHLTHref   0.80582    0.35118   2.295  0.02205 *  
## SMOKDAY2ref  -0.44586    0.30106  -1.481  0.13907    
## ECIGNOWref    1.07632    0.46705   2.304  0.02149 *  
## CVDSTRK3ref   0.06605    0.68031   0.097  0.92268    
## CVDCRHD4ref   0.69074    0.71454   0.967  0.33404    
## DIABETE3ref  -0.03410    0.35035  -0.097  0.92250    
## ADDEPEV2ref  -0.49793    0.27839  -1.789  0.07411 .  
## HAVARTH3ref  -0.22729    0.29748  -0.764  0.44510    
## CHCCOPD1ref   0.01137    0.45798   0.025  0.98020    
## DEAFref       0.11685    0.36499   0.320  0.74895    
## BLINDref     -1.05938    0.40282  -2.630  0.00873 ** 
## DECIDEref    -0.05746    0.29643  -0.194  0.84635    
## DIFFWALKref   0.08239    0.37092   0.222  0.82428    
## DIFFDRESref   1.15865    0.51305   2.258  0.02423 *  
## DIFFALONref  -0.37283    0.43841  -0.850  0.39539    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 0.9092306)
## 
## Number of Fisher Scoring iterations: 5
confint(alr)
##                    2.5 %       97.5 %
## (Intercept)  -0.03445004  1.913140096
## SEXref        0.23413894  1.175684310
## MARITALref   -0.71786684  0.354900063
## EDUCAref     -0.10020683  0.956832181
## EMPLOY1ref   -0.43589540  0.600668617
## INCOME2ref   -0.64531553  0.717964992
## X_BMI5CATref -0.29508577  0.807339086
## X_AGEG5YRref -0.80432334  1.072465335
## CHILDRENref  -0.98020730 -0.007329393
## SDHBILLSref  -0.94902191  0.352367690
## HOWSAFE1ref  -0.63415198  0.728027871
## SDHFOODref   -0.50175454  0.826935338
## SDHMEALSref  -0.91266977  0.349588240
## SDHMONEYref  -0.95381855  0.100881330
## SDHSTRESref  -1.94074225 -0.823351148
## GENHLTHref   -0.87700195  0.251650215
## PHYSHLTHref  -0.24916776  1.046740733
## MENTHLTHref  -0.56518645  0.676756989
## POORHLTHref   0.11751615  1.494122149
## SMOKDAY2ref  -1.03593394  0.144214402
## ECIGNOWref    0.16091432  1.991726489
## CVDSTRK3ref  -1.26733133  1.399435835
## CVDCRHD4ref  -0.70974218  2.091217917
## DIABETE3ref  -0.72077877  0.652587559
## ADDEPEV2ref  -1.04356604  0.047699936
## HAVARTH3ref  -0.81034830  0.355769384
## CHCCOPD1ref  -0.88626319  0.908999736
## DEAFref      -0.59851962  0.832219873
## BLINDref     -1.84889799 -0.269855220
## DECIDEref    -0.63846005  0.523531803
## DIFFWALKref  -0.64458770  0.809372969
## DIFFDRESref   0.15308752  2.164212023
## DIFFALONref  -1.23209027  0.486431796
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    2.5583053    2.0236678    0.8340321    1.5346659    1.0858755    1.0369925 
## X_BMI5CATref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref   SDHFOODref 
##    1.2919163    1.1434740    0.6103221    0.7420586    1.0480570    1.1765547 
##  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref  MENTHLTHref 
##    0.7546202    0.6528104    0.2510642    0.7314870    1.4900154    1.0573706 
##  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref  DIABETE3ref 
##    2.2385294    0.6402736    2.9338642    1.0682825    1.9951872    0.9664791 
##  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref    DECIDEref 
##    0.6077856    0.7966901    1.0114331    1.1239510    0.3466719    0.9441558 
##  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    1.0858821    3.1856290    0.6887828
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR     2.5 %    97.5 %
## (Intercept)  2.5583053 0.9661366 6.7743275
## SEXref       2.0236678 1.2638201 3.2403596
## MARITALref   0.8340321 0.4877917 1.4260381
## EDUCAref     1.5346659 0.9046503 2.6034362
## EMPLOY1ref   1.0858755 0.6466854 1.8233375
## INCOME2ref   1.0369925 0.5244970 2.0502567
## X_BMI5CATref 1.2919163 0.7444677 2.2419344
## X_AGEG5YRref 1.1434740 0.4473906 2.9225758
## CHILDRENref  0.6103221 0.3752333 0.9926974
## SDHBILLSref  0.7420586 0.3871195 1.4224314
## HOWSAFE1ref  1.0480570 0.5303851 2.0709923
## SDHFOODref   1.1765547 0.6054674 2.2863013
## SDHMEALSref  0.7546202 0.4014510 1.4184834
## SDHMONEYref  0.6528104 0.3852670 1.1061454
## SDHSTRESref  0.2510642 0.1435973 0.4389582
## GENHLTHref   0.7314870 0.4160283 1.2861461
## PHYSHLTHref  1.4900154 0.7794492 2.8483524
## MENTHLTHref  1.0573706 0.5682542 1.9674868
## POORHLTHref  2.2385294 1.1246998 4.4554236
## SMOKDAY2ref  0.6402736 0.3548948 1.1551317
## ECIGNOWref   2.9338642 1.1745843 7.3281749
## CVDSTRK3ref  1.0682825 0.2815821 4.0529128
## CVDCRHD4ref  1.9951872 0.4917710 8.0947679
## DIABETE3ref  0.9664791 0.4863733 1.9205038
## ADDEPEV2ref  0.6077856 0.3521965 1.0488559
## HAVARTH3ref  0.7966901 0.4447032 1.4272784
## CHCCOPD1ref  1.0114331 0.4121932 2.4818388
## DEAFref      1.1239510 0.5496247 2.2984153
## BLINDref     0.3466719 0.1574105 0.7634900
## DECIDEref    0.9441558 0.5281051 1.6879787
## DIFFWALKref  1.0858821 0.5248789 2.2464989
## DIFFDRESref  3.1856290 1.1654270 8.7077377
## DIFFALONref  0.6887828 0.2916822 1.6265022
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR     2.5 %    97.5 %
## SEXref       2.0236678 1.2638201 3.2403596
## MARITALref   0.8340321 0.4877917 1.4260381
## EDUCAref     1.5346659 0.9046503 2.6034362
## EMPLOY1ref   1.0858755 0.6466854 1.8233375
## INCOME2ref   1.0369925 0.5244970 2.0502567
## X_BMI5CATref 1.2919163 0.7444677 2.2419344
## X_AGEG5YRref 1.1434740 0.4473906 2.9225758
## CHILDRENref  0.6103221 0.3752333 0.9926974
## SDHBILLSref  0.7420586 0.3871195 1.4224314
## HOWSAFE1ref  1.0480570 0.5303851 2.0709923
## SDHFOODref   1.1765547 0.6054674 2.2863013
## SDHMEALSref  0.7546202 0.4014510 1.4184834
## SDHMONEYref  0.6528104 0.3852670 1.1061454
## SDHSTRESref  0.2510642 0.1435973 0.4389582
## GENHLTHref   0.7314870 0.4160283 1.2861461
## PHYSHLTHref  1.4900154 0.7794492 2.8483524
## MENTHLTHref  1.0573706 0.5682542 1.9674868
## POORHLTHref  2.2385294 1.1246998 4.4554236
## SMOKDAY2ref  0.6402736 0.3548948 1.1551317
## ECIGNOWref   2.9338642 1.1745843 7.3281749
## CVDSTRK3ref  1.0682825 0.2815821 4.0529128
## CVDCRHD4ref  1.9951872 0.4917710 8.0947679
## DIABETE3ref  0.9664791 0.4863733 1.9205038
## ADDEPEV2ref  0.6077856 0.3521965 1.0488559
## HAVARTH3ref  0.7966901 0.4447032 1.4272784
## CHCCOPD1ref  1.0114331 0.4121932 2.4818388
## DEAFref      1.1239510 0.5496247 2.2984153
## BLINDref     0.3466719 0.1574105 0.7634900
## DECIDEref    0.9441558 0.5281051 1.6879787
## DIFFWALKref  1.0858821 0.5248789 2.2464989
## DIFFDRESref  3.1856290 1.1654270 8.7077377
## DIFFALONref  0.6887828 0.2916822 1.6265022
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 1.96 1.41 2.72 SEX 2.02 1.26 3.24
MARITALref 1.90 1.37 2.65 MARITAL 0.83 0.49 1.43
EDUCAref 1.09 0.75 1.59 EDUCA 1.53 0.90 2.60
EMPLOY1ref 1.95 1.40 2.72 EMPLOY1 1.09 0.65 1.82
INCOME2ref 1.09 0.68 1.75 INCOME2 1.04 0.52 2.05
X_BMI5CATref 1.54 1.04 2.27 X_BMI5CAT 1.29 0.74 2.24
X_AGEG5YRref 0.72 0.41 1.25 X_AGEG5YR 1.14 0.45 2.92
CHILDRENref 0.87 0.63 1.21 CHILDREN 0.61 0.38 0.99
SDHBILLSref 0.34 0.23 0.50 SDHBILLS 0.74 0.39 1.42
HOWSAFE1ref 0.50 0.31 0.82 HOWSAFE1 1.05 0.53 2.07
SDHFOODref 0.44 0.31 0.63 SDHFOOD 1.18 0.61 2.29
SDHMEALSref 0.43 0.30 0.61 SDHMEALS 0.75 0.40 1.42
SDHMONEYref 0.52 0.37 0.73 SDHMONEY 0.65 0.39 1.11
SDHSTRESref 0.11 0.07 0.18 SDHSTRES 0.25 0.14 0.44
GENHLTHref 0.31 0.21 0.44 GENHLTH 0.73 0.42 1.29
PHYSHLTHref 4.34 2.88 6.55 PHYSHLTH 1.49 0.78 2.85
MENTHLTHref 4.31 2.89 6.44 MENTHLTH 1.06 0.57 1.97
POORHLTHref 4.21 2.53 6.98 POORHLTH 2.24 1.12 4.46
SMOKDAY2ref 0.35 0.24 0.52 SMOKDAY2 0.64 0.35 1.16
ECIGNOWref 0.63 0.23 1.75 ECIGNOW 2.93 1.17 7.33
CVDSTRK3ref 0.31 0.13 0.79 CVDSTRK3 1.07 0.28 4.05
CVDCRHD4ref 0.44 0.22 0.91 CVDCRHD4 2.00 0.49 8.09
DIABETE3ref 0.85 0.53 1.34 DIABETE3 0.97 0.49 1.92
ADDEPEV2ref 0.26 0.18 0.38 ADDEPEV2 0.61 0.35 1.05
HAVARTH3ref 0.43 0.29 0.63 HAVARTH3 0.80 0.44 1.43
CHCCOPD1ref 0.29 0.15 0.55 CHCCOPD1 1.01 0.41 2.48
DEAFref 0.45 0.23 0.88 DEAF 1.12 0.55 2.30
BLINDref 0.46 0.27 0.78 BLIND 0.35 0.16 0.76
DECIDEref 0.21 0.14 0.31 DECIDE 0.94 0.53 1.69
DIFFWALKref 0.32 0.22 0.49 DIFFWALK 1.09 0.52 2.25
DIFFDRESref 0.34 0.19 0.62 DIFFDRES 3.19 1.17 8.71
DIFFALONref 0.16 0.10 0.28 DIFFALON 0.69 0.29 1.63
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR
ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

#Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

SLEPTIM1 - Hours per sleep at night

#Binomial logistic regression for each variable
or<-svyglm(SLEPTIM1~SEX, family=quasibinomial,design=svydesNW)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat
or <- svyglm(SLEPTIM1~ MARITAL, family = quasibinomial, design = svydesNW)
b <- or_fun("MARITAL")

or <- svyglm(SLEPTIM1~ EDUCA, family = quasibinomial, design = svydesNW)
c <- or_fun("EDUCA")

or <- svyglm(SLEPTIM1~ EMPLOY1, family = quasibinomial, design = svydesNW)
d <- or_fun("EMPLOY1")

or <- svyglm(SLEPTIM1~ INCOME2, family = quasibinomial, design = svydesNW)
e <- or_fun("INCOME2")

or <- svyglm(SLEPTIM1~ X_BMI5CAT, family = quasibinomial, design = svydesNW)
f <- or_fun("X_BMI5CAT")

or <- svyglm(SLEPTIM1~ X_AGEG5YR, family = quasibinomial, design = svydesNW)
h <- or_fun("X_AGEG5YR")

or <- svyglm(SLEPTIM1~ CHILDREN, family = quasibinomial, design = svydesNW)
i <- or_fun("CHILDREN")

or <- svyglm(SLEPTIM1~ SDHBILLS, family = quasibinomial, design = svydesNW)
j <- or_fun("SDHBILLS")

or <- svyglm(SLEPTIM1~ HOWSAFE1, family = quasibinomial, design = svydesNW)
k <- or_fun("HOWSAFE1")

or <- svyglm(SLEPTIM1~ SDHFOOD, family = quasibinomial, design = svydesNW)
l <- or_fun("SDHFOOD")

or <- svyglm(SLEPTIM1~ SDHMEALS, family = quasibinomial, design = svydesNW)
m <- or_fun("SDHMEALS")

or <- svyglm(SLEPTIM1~ SDHMONEY, family = quasibinomial, design = svydesNW)
n <- or_fun("SDHMONEY")

or <- svyglm(SLEPTIM1~ SDHSTRES, family = quasibinomial, design = svydesNW)
o <- or_fun("SDHSTRES")

or <- svyglm(SLEPTIM1~ GENHLTH, family = quasibinomial, design = svydesNW)
p <- or_fun("GENHLTH")

or <- svyglm(SLEPTIM1~ PHYSHLTH, family = quasibinomial, design = svydesNW)
q <- or_fun("PHYSHLTH")

or <- svyglm(SLEPTIM1~ MENTHLTH, family = quasibinomial, design = svydesNW)
r <- or_fun("MENTHLTH")

or <- svyglm(SLEPTIM1~ POORHLTH, family = quasibinomial, design = svydesNW)
s <- or_fun("POORHLTH")

or <- svyglm(SLEPTIM1~ SMOKDAY2, family = quasibinomial, design = svydesNW)
t <- or_fun("SMOKDAY2")

or <- svyglm(SLEPTIM1~ ECIGNOW, family = quasibinomial, design = svydesNW)
u <- or_fun("ECIGNOW")

or <- svyglm(SLEPTIM1~ CVDSTRK3, family = quasibinomial, design = svydesNW)
v <- or_fun("CVDSTRK3")

or <- svyglm(SLEPTIM1~ CVDCRHD4, family = quasibinomial, design = svydesNW)
w <- or_fun("CVDCRHD4")

or <- svyglm(SLEPTIM1~ DIABETE3, family = quasibinomial, design = svydesNW)
x <- or_fun("DIABETE3")

or <- svyglm(SLEPTIM1~ ADDEPEV2, family = quasibinomial, design = svydesNW)
y <- or_fun("ADDEPEV2")

or <- svyglm(SLEPTIM1~ HAVARTH3, family = quasibinomial, design = svydesNW)
z <- or_fun("HAVARTH3")

or <- svyglm(SLEPTIM1~ CHCCOPD1, family = quasibinomial, design = svydesNW)
aa <- or_fun("CHCCOPD1")

or <- svyglm(SLEPTIM1~ DEAF, family = quasibinomial, design = svydesNW)
bb <- or_fun("DEAF")

or <- svyglm(SLEPTIM1~ BLIND, family = quasibinomial, design = svydesNW)
cc <- or_fun("BLIND")

or <- svyglm(SLEPTIM1~ DECIDE, family = quasibinomial, design = svydesNW)
dd <- or_fun("DECIDE")

or <- svyglm(SLEPTIM1~ DIFFWALK, family = quasibinomial, design = svydesNW)
ee <- or_fun("DIFFWALK")

or <- svyglm(SLEPTIM1~ DIFFDRES, family = quasibinomial, design = svydesNW)
ff <- or_fun("DIFFDRES")

or <- svyglm(SLEPTIM1~ DIFFALON, family = quasibinomial, design = svydesNW)
gg <- or_fun("DIFFALON")



# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 +
                X_BMI5CAT  + X_AGEG5YR + CHILDREN  + SDHBILLS + 
                HOWSAFE1 + SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + 
                PHYSHLTH + MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW +
                CVDSTRK3 +  CVDCRHD4 + DIABETE3 + ADDEPEV2 + HAVARTH3 + 
                CHCCOPD1 + DEAF + BLIND + DECIDE + DIFFWALK + DIFFDRES +
                DIFFALON, family = quasibinomial, design = svydesNW)

summary(alr)
## 
## Call:
## svyglm(formula = SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_AGEG5YR + CHILDREN + SDHBILLS + HOWSAFE1 + 
##     SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + 
##     MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + CVDCRHD4 + 
##     DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + 
##     DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydesNW, 
##     family = quasibinomial)
## 
## Survey design:
## subset(svydes, RACE != "White only, non-Hispanic")
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  -0.486463   0.412058  -1.181  0.23811   
## SEXref        0.003219   0.197687   0.016  0.98701   
## MARITALref    0.151877   0.206031   0.737  0.46123   
## EDUCAref      0.092460   0.221439   0.418  0.67639   
## EMPLOY1ref   -0.072104   0.199899  -0.361  0.71841   
## INCOME2ref    0.089505   0.312375   0.287  0.77454   
## X_BMI5CATref -0.012613   0.216676  -0.058  0.95359   
## X_AGEG5YRref -0.988308   0.357519  -2.764  0.00583 **
## CHILDRENref   0.078938   0.197141   0.400  0.68895   
## SDHBILLSref   0.344526   0.294958   1.168  0.24312   
## HOWSAFE1ref  -0.059916   0.330047  -0.182  0.85599   
## SDHFOODref    0.191431   0.327404   0.585  0.55891   
## SDHMEALSref  -0.252173   0.323163  -0.780  0.43542   
## SDHMONEYref   0.696371   0.215423   3.233  0.00127 **
## SDHSTRESref  -0.318749   0.292474  -1.090  0.27610   
## GENHLTHref   -0.559765   0.232160  -2.411  0.01612 * 
## PHYSHLTHref  -0.531784   0.263073  -2.021  0.04355 * 
## MENTHLTHref   0.216274   0.242082   0.893  0.37190   
## POORHLTHref   0.464774   0.317912   1.462  0.14413   
## SMOKDAY2ref  -0.052441   0.239235  -0.219  0.82654   
## ECIGNOWref    0.005501   0.484845   0.011  0.99095   
## CVDSTRK3ref   0.138494   0.514483   0.269  0.78785   
## CVDCRHD4ref   0.398824   0.500209   0.797  0.42549   
## DIABETE3ref  -0.350238   0.316336  -1.107  0.26854   
## ADDEPEV2ref   0.088590   0.250363   0.354  0.72354   
## HAVARTH3ref  -0.445409   0.261940  -1.700  0.08942 . 
## CHCCOPD1ref  -0.245914   0.390360  -0.630  0.52889   
## DEAFref      -0.136697   0.373910  -0.366  0.71476   
## BLINDref     -0.349231   0.370686  -0.942  0.34640   
## DECIDEref    -0.108435   0.270561  -0.401  0.68869   
## DIFFWALKref   0.352457   0.308539   1.142  0.25364   
## DIFFDRESref  -0.188618   0.409472  -0.461  0.64518   
## DIFFALONref  -0.088949   0.403318  -0.221  0.82550   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 0.9381753)
## 
## Number of Fisher Scoring iterations: 4
confint(alr)
##                   2.5 %      97.5 %
## (Intercept)  -1.2940809  0.32115487
## SEXref       -0.3842414  0.39067880
## MARITALref   -0.2519360  0.55568984
## EDUCAref     -0.3415527  0.52647301
## EMPLOY1ref   -0.4638977  0.31969036
## INCOME2ref   -0.5227375  0.70174820
## X_BMI5CATref -0.4372905  0.41206367
## X_AGEG5YRref -1.6890332 -0.28758345
## CHILDRENref  -0.3074518  0.46532802
## SDHBILLSref  -0.2335809  0.92263244
## HOWSAFE1ref  -0.7067960  0.58696401
## SDHFOODref   -0.4502697  0.83313154
## SDHMEALSref  -0.8855616  0.38121522
## SDHMONEYref   0.2741502  1.11859239
## SDHSTRESref  -0.8919863  0.25448928
## GENHLTHref   -1.0147894 -0.10474074
## PHYSHLTHref  -1.0473977 -0.01616926
## MENTHLTHref  -0.2581977  0.69074632
## POORHLTHref  -0.1583230  1.08787007
## SMOKDAY2ref  -0.5213328  0.41645034
## ECIGNOWref   -0.9447788  0.95577994
## CVDSTRK3ref  -0.8698749  1.14686201
## CVDCRHD4ref  -0.5815672  1.37921515
## DIABETE3ref  -0.9702458  0.26976957
## ADDEPEV2ref  -0.4021119  0.57929123
## HAVARTH3ref  -0.9588008  0.06798382
## CHCCOPD1ref  -1.0110050  0.51917635
## DEAFref      -0.8695462  0.59615319
## BLINDref     -1.0757615  0.37729915
## DECIDEref    -0.6387246  0.42185562
## DIFFWALKref  -0.2522685  0.95718333
## DIFFDRESref  -0.9911683  0.61393303
## DIFFALONref  -0.8794376  0.70153864
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    0.6147971    1.0032239    1.1640170    1.0968694    0.9304344    1.0936332 
## X_BMI5CATref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref   SDHFOODref 
##    0.9874658    0.3722058    1.0821373    1.4113204    0.9418437    1.2109811 
##  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref  MENTHLTHref 
##    0.7771101    2.0064586    0.7270584    0.5713433    0.5875561    1.2414429 
##  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref  DIABETE3ref 
##    1.5916537    0.9489101    1.0055157    1.1485423    1.4900713    0.7045203 
##  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref    DECIDEref 
##    1.0926322    0.6405625    0.7819892    0.8722349    0.7052301    0.8972376 
##  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    1.4225591    0.8281031    0.9148918
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR     2.5 %    97.5 %
## (Intercept)  0.6147971 0.2741497 1.3787191
## SEXref       1.0032239 0.6809670 1.4779837
## MARITALref   1.1640170 0.7772945 1.7431431
## EDUCAref     1.0968694 0.7106660 1.6929507
## EMPLOY1ref   0.9304344 0.6288279 1.3767014
## INCOME2ref   1.0936332 0.5928953 2.0172762
## X_BMI5CATref 0.9874658 0.6457838 1.5099306
## X_AGEG5YRref 0.3722058 0.1846980 0.7500740
## CHILDRENref  1.0821373 0.7353183 1.5925365
## SDHBILLSref  1.4113204 0.7916935 2.5159047
## HOWSAFE1ref  0.9418437 0.4932220 1.7985198
## SDHFOODref   1.2109811 0.6374562 2.3005116
## SDHMEALSref  0.7771101 0.4124825 1.4640627
## SDHMONEYref  2.0064586 1.3154123 3.0605431
## SDHSTRESref  0.7270584 0.4098409 1.2898027
## GENHLTHref   0.5713433 0.3624788 0.9005580
## PHYSHLTHref  0.5875561 0.3508496 0.9839608
## MENTHLTHref  1.2414429 0.7724425 1.9952040
## POORHLTHref  1.5916537 0.8535740 2.9679458
## SMOKDAY2ref  0.9489101 0.5937287 1.5165687
## ECIGNOWref   1.0055157 0.3887655 2.6006982
## CVDSTRK3ref  1.1485423 0.4190040 3.1482981
## CVDCRHD4ref  1.4900713 0.5590216 3.9717832
## DIABETE3ref  0.7045203 0.3789899 1.3096626
## ADDEPEV2ref  1.0926322 0.6689059 1.7847730
## HAVARTH3ref  0.6405625 0.3833523 1.0703480
## CHCCOPD1ref  0.7819892 0.3638531 1.6806428
## DEAFref      0.8722349 0.4191417 1.8151229
## BLINDref     0.7052301 0.3410380 1.4583405
## DECIDEref    0.8972376 0.5279653 1.5247884
## DIFFWALKref  1.4225591 0.7770360 2.6043505
## DIFFDRESref  0.8281031 0.3711428 1.8476841
## DIFFALONref  0.9148918 0.4150162 2.0168535
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR     2.5 %    97.5 %
## SEXref       1.0032239 0.6809670 1.4779837
## MARITALref   1.1640170 0.7772945 1.7431431
## EDUCAref     1.0968694 0.7106660 1.6929507
## EMPLOY1ref   0.9304344 0.6288279 1.3767014
## INCOME2ref   1.0936332 0.5928953 2.0172762
## X_BMI5CATref 0.9874658 0.6457838 1.5099306
## X_AGEG5YRref 0.3722058 0.1846980 0.7500740
## CHILDRENref  1.0821373 0.7353183 1.5925365
## SDHBILLSref  1.4113204 0.7916935 2.5159047
## HOWSAFE1ref  0.9418437 0.4932220 1.7985198
## SDHFOODref   1.2109811 0.6374562 2.3005116
## SDHMEALSref  0.7771101 0.4124825 1.4640627
## SDHMONEYref  2.0064586 1.3154123 3.0605431
## SDHSTRESref  0.7270584 0.4098409 1.2898027
## GENHLTHref   0.5713433 0.3624788 0.9005580
## PHYSHLTHref  0.5875561 0.3508496 0.9839608
## MENTHLTHref  1.2414429 0.7724425 1.9952040
## POORHLTHref  1.5916537 0.8535740 2.9679458
## SMOKDAY2ref  0.9489101 0.5937287 1.5165687
## ECIGNOWref   1.0055157 0.3887655 2.6006982
## CVDSTRK3ref  1.1485423 0.4190040 3.1482981
## CVDCRHD4ref  1.4900713 0.5590216 3.9717832
## DIABETE3ref  0.7045203 0.3789899 1.3096626
## ADDEPEV2ref  1.0926322 0.6689059 1.7847730
## HAVARTH3ref  0.6405625 0.3833523 1.0703480
## CHCCOPD1ref  0.7819892 0.3638531 1.6806428
## DEAFref      0.8722349 0.4191417 1.8151229
## BLINDref     0.7052301 0.3410380 1.4583405
## DECIDEref    0.8972376 0.5279653 1.5247884
## DIFFWALKref  1.4225591 0.7770360 2.6043505
## DIFFDRESref  0.8281031 0.3711428 1.8476841
## DIFFALONref  0.9148918 0.4150162 2.0168535
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 0.93 0.74 1.18 SEX 1.00 0.68 1.48
MARITALref 1.48 1.17 1.87 MARITAL 1.16 0.78 1.74
EDUCAref 0.80 0.61 1.05 EDUCA 1.10 0.71 1.69
EMPLOY1ref 1.00 0.79 1.27 EMPLOY1 0.93 0.63 1.38
INCOME2ref 0.91 0.65 1.30 INCOME2 1.09 0.59 2.02
X_BMI5CATref 1.26 0.95 1.66 X_BMI5CAT 0.99 0.65 1.51
X_AGEG5YRref 0.46 0.30 0.72 X_AGEG5YR 0.37 0.18 0.75
CHILDRENref 0.88 0.69 1.12 CHILDREN 1.08 0.74 1.59
SDHBILLSref 1.19 0.83 1.71 SDHBILLS 1.41 0.79 2.52
HOWSAFE1ref 1.02 0.64 1.63 HOWSAFE1 0.94 0.49 1.80
SDHFOODref 1.19 0.88 1.61 SDHFOOD 1.21 0.64 2.30
SDHMEALSref 1.08 0.80 1.44 SDHMEALS 0.78 0.41 1.46
SDHMONEYref 1.65 1.29 2.10 SDHMONEY 2.01 1.32 3.06
SDHSTRESref 0.56 0.36 0.87 SDHSTRES 0.73 0.41 1.29
GENHLTHref 0.66 0.48 0.89 GENHLTH 0.57 0.36 0.90
PHYSHLTHref 1.26 0.87 1.82 PHYSHLTH 0.59 0.35 0.98
MENTHLTHref 1.82 1.27 2.60 MENTHLTH 1.24 0.77 2.00
POORHLTHref 1.59 0.99 2.55 POORHLTH 1.59 0.85 2.97
SMOKDAY2ref 0.73 0.53 1.01 SMOKDAY2 0.95 0.59 1.52
ECIGNOWref 0.73 0.36 1.47 ECIGNOW 1.01 0.39 2.60
CVDSTRK3ref 0.59 0.25 1.40 CVDSTRK3 1.15 0.42 3.15
CVDCRHD4ref 0.61 0.28 1.30 CVDCRHD4 1.49 0.56 3.97
DIABETE3ref 0.64 0.42 0.99 DIABETE3 0.70 0.38 1.31
ADDEPEV2ref 0.71 0.51 1.00 ADDEPEV2 1.09 0.67 1.78
HAVARTH3ref 0.75 0.53 1.06 HAVARTH3 0.64 0.38 1.07
CHCCOPD1ref 0.62 0.34 1.14 CHCCOPD1 0.78 0.36 1.68
DEAFref 0.63 0.34 1.20 DEAF 0.87 0.42 1.82
BLINDref 0.86 0.51 1.46 BLIND 0.71 0.34 1.46
DECIDEref 0.70 0.49 1.01 DECIDE 0.90 0.53 1.52
DIFFWALKref 0.90 0.62 1.31 DIFFWALK 1.42 0.78 2.60
DIFFDRESref 0.63 0.35 1.14 DIFFDRES 0.83 0.37 1.85
DIFFALONref 0.57 0.34 0.95 DIFFALON 0.91 0.42 2.02
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR
ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

#Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) +
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

AA

ADSLEEP - Difficulty sleeping past 14 days

svydesAA<-subset(svydes,RACE == "Black only, non-Hispanic")

#Binomial logistic regression for each variable
or<-svyglm(ADSLEEP~SEX, family=quasibinomial,design=svydesAA)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat

or <- svyglm(ADSLEEP~ MARITAL, family = quasibinomial, design = svydesAA)
b <- or_fun("MARITAL")

or <- svyglm(ADSLEEP~ EDUCA, family = quasibinomial, design = svydesAA)
c <- or_fun("EDUCA")

or <- svyglm(ADSLEEP~ EMPLOY1, family = quasibinomial, design = svydesAA)
d <- or_fun("EMPLOY1")

or <- svyglm(ADSLEEP~ INCOME2, family = quasibinomial, design = svydesAA)
e <- or_fun("INCOME2")

or <- svyglm(ADSLEEP~ X_BMI5CAT, family = quasibinomial, design = svydesAA)
f <- or_fun("X_BMI5CAT")

or <- svyglm(ADSLEEP~ X_AGEG5YR, family = quasibinomial, design = svydesAA)
h <- or_fun("X_AGEG5YR")

or <- svyglm(ADSLEEP~ CHILDREN, family = quasibinomial, design = svydesAA)
i <- or_fun("CHILDREN")

or <- svyglm(ADSLEEP~ SDHBILLS, family = quasibinomial, design = svydesAA)
j <- or_fun("SDHBILLS")

or <- svyglm(ADSLEEP~ HOWSAFE1, family = quasibinomial, design = svydesAA)
k <- or_fun("HOWSAFE1")

or <- svyglm(ADSLEEP~ SDHFOOD, family = quasibinomial, design = svydesAA)
l <- or_fun("SDHFOOD")

or <- svyglm(ADSLEEP~ SDHMEALS, family = quasibinomial, design = svydesAA)
m <- or_fun("SDHMEALS")

or <- svyglm(ADSLEEP~ SDHMONEY, family = quasibinomial, design = svydesAA)
n <- or_fun("SDHMONEY")

or <- svyglm(ADSLEEP~ SDHSTRES, family = quasibinomial, design = svydesAA)
o <- or_fun("SDHSTRES")

or <- svyglm(ADSLEEP~ GENHLTH, family = quasibinomial, design = svydesAA)
p <- or_fun("GENHLTH")

or <- svyglm(ADSLEEP~ PHYSHLTH, family = quasibinomial, design = svydesAA)
q <- or_fun("PHYSHLTH")

or <- svyglm(ADSLEEP~ MENTHLTH, family = quasibinomial, design = svydesAA)
r <- or_fun("MENTHLTH")

or <- svyglm(ADSLEEP~ POORHLTH, family = quasibinomial, design = svydesAA)
s <- or_fun("POORHLTH")

or <- svyglm(ADSLEEP~ SMOKDAY2, family = quasibinomial, design = svydesAA)
t <- or_fun("SMOKDAY2")

or <- svyglm(ADSLEEP~ ECIGNOW, family = quasibinomial, design = svydesAA)
u <- or_fun("ECIGNOW")

or <- svyglm(ADSLEEP~ CVDSTRK3, family = quasibinomial, design = svydesAA)
v <- or_fun("CVDSTRK3")

or <- svyglm(ADSLEEP~ CVDCRHD4, family = quasibinomial, design = svydesAA)
w <- or_fun("CVDCRHD4")

or <- svyglm(ADSLEEP~ DIABETE3, family = quasibinomial, design = svydesAA)
x <- or_fun("DIABETE3")

or <- svyglm(ADSLEEP~ ADDEPEV2, family = quasibinomial, design = svydesAA)
y <- or_fun("ADDEPEV2")

or <- svyglm(ADSLEEP~ HAVARTH3, family = quasibinomial, design = svydesAA)
z <- or_fun("HAVARTH3")

or <- svyglm(ADSLEEP~ CHCCOPD1, family = quasibinomial, design = svydesAA)
aa <- or_fun("CHCCOPD1")

or <- svyglm(ADSLEEP~ DEAF, family = quasibinomial, design = svydesAA)
bb <- or_fun("DEAF")

or <- svyglm(ADSLEEP~ BLIND, family = quasibinomial, design = svydesAA)
cc <- or_fun("BLIND")

or <- svyglm(ADSLEEP~ DECIDE, family = quasibinomial, design = svydesAA)
dd <- or_fun("DECIDE")

or <- svyglm(ADSLEEP~ DIFFWALK, family = quasibinomial, design = svydesAA)
ee <- or_fun("DIFFWALK")

or <- svyglm(ADSLEEP~ DIFFDRES, family = quasibinomial, design = svydesAA)
ff <- or_fun("DIFFDRES")

or <- svyglm(ADSLEEP~ DIFFALON, family = quasibinomial, design = svydesAA)
gg <- or_fun("DIFFALON")



# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 + X_BMI5CAT
               + X_AGEG5YR + CHILDREN  + SDHBILLS + HOWSAFE1 + SDHFOOD + 
                SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + MENTHLTH + 
                POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 +  CVDCRHD4 + DIABETE3 + 
                ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + DECIDE + 
                DIFFWALK + DIFFDRES + DIFFALON, family = quasibinomial, 
              design = svydesAA)

summary(alr)
## 
## Call:
## svyglm(formula = ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_AGEG5YR + CHILDREN + SDHBILLS + HOWSAFE1 + 
##     SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + 
##     MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + CVDCRHD4 + 
##     DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + 
##     DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydesAA, 
##     family = quasibinomial)
## 
## Survey design:
## subset(svydes, RACE == "Black only, non-Hispanic")
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  -1.31234    1.26157  -1.040  0.30035   
## SEXref        0.43239    0.74355   0.582  0.56200   
## MARITALref   -0.39624    0.65724  -0.603  0.54774   
## EDUCAref      0.13641    0.55015   0.248  0.80461   
## EMPLOY1ref   -0.27664    0.61929  -0.447  0.65591   
## INCOME2ref    0.32929    0.75264   0.438  0.66255   
## X_BMI5CATref  0.47065    0.63570   0.740  0.46055   
## X_AGEG5YRref  0.85310    1.35886   0.628  0.53135   
## CHILDRENref  -1.19006    0.59083  -2.014  0.04626 * 
## SDHBILLSref   1.11476    0.83952   1.328  0.18679   
## HOWSAFE1ref   1.62134    0.80180   2.022  0.04543 * 
## SDHFOODref    1.74079    0.71772   2.425  0.01680 * 
## SDHMEALSref  -1.86351    0.94254  -1.977  0.05036 . 
## SDHMONEYref  -1.00565    0.66875  -1.504  0.13531   
## SDHSTRESref  -2.24050    0.85175  -2.630  0.00966 **
## GENHLTHref   -0.08057    0.69527  -0.116  0.90794   
## PHYSHLTHref   0.52187    0.80097   0.652  0.51597   
## MENTHLTHref   0.77870    0.78212   0.996  0.32147   
## POORHLTHref   2.91294    1.01200   2.878  0.00475 **
## SMOKDAY2ref   0.74699    0.68089   1.097  0.27484   
## ECIGNOWref   -0.58684    0.90278  -0.650  0.51693   
## CVDSTRK3ref   0.82761    1.22117   0.678  0.49928   
## CVDCRHD4ref   1.69176    1.69764   0.997  0.32103   
## DIABETE3ref   0.06063    0.90822   0.067  0.94689   
## ADDEPEV2ref  -0.76009    0.64882  -1.171  0.24376   
## HAVARTH3ref  -0.53299    0.70415  -0.757  0.45060   
## CHCCOPD1ref   0.59693    1.09170   0.547  0.58556   
## DEAFref      -0.94386    0.96071  -0.982  0.32788   
## BLINDref     -2.10381    0.78541  -2.679  0.00845 **
## DECIDEref     1.11495    0.67857   1.643  0.10303   
## DIFFWALKref   1.42801    0.96992   1.472  0.14360   
## DIFFDRESref   1.60295    0.91496   1.752  0.08238 . 
## DIFFALONref  -0.73187    0.95972  -0.763  0.44723   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 1.145577)
## 
## Number of Fisher Scoring iterations: 6
confint(alr)
##                    2.5 %      97.5 %
## (Intercept)  -3.78497723  1.16029429
## SEXref       -1.02493369  1.88971420
## MARITALref   -1.68440340  0.89191896
## EDUCAref     -0.94186690  1.21467812
## EMPLOY1ref   -1.49042940  0.93715906
## INCOME2ref   -1.14586949  1.80443951
## X_BMI5CATref -0.77529914  1.71659381
## X_AGEG5YRref -1.81021458  3.51640577
## CHILDRENref  -2.34805778 -0.03206520
## SDHBILLSref  -0.53066042  2.76018516
## HOWSAFE1ref   0.04983491  3.19283909
## SDHFOODref    0.33409400  3.14748835
## SDHMEALSref  -3.71085296 -0.01617393
## SDHMONEYref  -2.31637915  0.30507431
## SDHSTRESref  -3.90989333 -0.57110923
## GENHLTHref   -1.44326928  1.28212398
## PHYSHLTHref  -1.04801257  2.09174414
## MENTHLTHref  -0.75422479  2.31162190
## POORHLTHref   0.92946733  4.89641535
## SMOKDAY2ref  -0.58753290  2.08150938
## ECIGNOWref   -2.35625627  1.18257870
## CVDSTRK3ref  -1.56584785  3.22106535
## CVDCRHD4ref  -1.63555527  5.01907477
## DIABETE3ref  -1.71945543  1.84071311
## ADDEPEV2ref  -2.03174860  0.51157474
## HAVARTH3ref  -1.91309747  0.84710983
## CHCCOPD1ref  -1.54276704  2.73661910
## DEAFref      -2.82681730  0.93908767
## BLINDref     -3.64318698 -0.56443159
## DECIDEref    -0.21502311  2.44492100
## DIFFWALKref  -0.47300293  3.32901431
## DIFFDRESref  -0.19032439  3.39623375
## DIFFALONref  -2.61289272  1.14914621
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    0.2691890    1.5409364    0.6728437    1.1461467    0.7583311    1.3899740 
## X_BMI5CATref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref   SDHFOODref 
##    1.6010303    2.3469007    0.3042026    3.0488436    5.0598508    5.7018528 
##  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref  MENTHLTHref 
##    0.1551266    0.3658059    0.1064052    0.9225879    1.6851689    2.1786350 
##  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref  DIABETE3ref 
##   18.4108717    2.1106337    0.5560824    2.2878414    5.4290260    1.0625045 
##  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref    DECIDEref 
##    0.4676258    0.5868454    1.8165263    0.3891210    0.1219908    3.0494125 
##  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    4.1703739    4.9676887    0.4810071
exp(cbind(AOR = coef(alr), confint(alr)))
##                     AOR      2.5 %      97.5 %
## (Intercept)   0.2691890 0.02270938   3.1908722
## SEXref        1.5409364 0.35882026   6.6174771
## MARITALref    0.6728437 0.18555510   2.4398070
## EDUCAref      1.1461467 0.38989925   3.3692094
## EMPLOY1ref    0.7583311 0.22527590   2.5527190
## INCOME2ref    1.3899740 0.31794734   6.0765647
## X_BMI5CATref  1.6010303 0.46056599   5.5655389
## X_AGEG5YRref  2.3469007 0.16361902  33.6632174
## CHILDRENref   0.3042026 0.09555457   0.9684434
## SDHBILLSref   3.0488436 0.58821637  15.8027688
## HOWSAFE1ref   5.0598508 1.05109756  24.3574824
## SDHFOODref    5.7018528 1.39667442  23.2775260
## SDHMEALSref   0.1551266 0.02445665   0.9839562
## SDHMONEYref   0.3658059 0.09863006   1.3567258
## SDHSTRESref   0.1064052 0.02004264   0.5648985
## GENHLTHref    0.9225879 0.23615444   3.6042870
## PHYSHLTHref   1.6851689 0.35063392   8.0990287
## MENTHLTHref   2.1786350 0.47037511  10.0907776
## POORHLTHref  18.4108717 2.53315948 133.8092599
## SMOKDAY2ref   2.1106337 0.55569655   8.0165598
## ECIGNOWref    0.5560824 0.09477437   3.2627771
## CVDSTRK3ref   2.2878414 0.20891081  25.0547982
## CVDCRHD4ref   5.4290260 0.19484415 151.2712781
## DIABETE3ref   1.0625045 0.17916369   6.3010300
## ADDEPEV2ref   0.4676258 0.13110607   1.6679157
## HAVARTH3ref   0.5868454 0.14762242   2.3328946
## CHCCOPD1ref   1.8165263 0.21378872  15.4347136
## DEAFref       0.3891210 0.05920097   2.5576469
## BLINDref      0.1219908 0.02616881   0.5686833
## DECIDEref     3.0494125 0.80652280  11.5296387
## DIFFWALKref   4.1703739 0.62312824  27.9108166
## DIFFDRESref   4.9676887 0.82669092  29.8514599
## DIFFALONref   0.4810071 0.07332214   3.1554976
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                     AOR      2.5 %      97.5 %
## SEXref        1.5409364 0.35882026   6.6174771
## MARITALref    0.6728437 0.18555510   2.4398070
## EDUCAref      1.1461467 0.38989925   3.3692094
## EMPLOY1ref    0.7583311 0.22527590   2.5527190
## INCOME2ref    1.3899740 0.31794734   6.0765647
## X_BMI5CATref  1.6010303 0.46056599   5.5655389
## X_AGEG5YRref  2.3469007 0.16361902  33.6632174
## CHILDRENref   0.3042026 0.09555457   0.9684434
## SDHBILLSref   3.0488436 0.58821637  15.8027688
## HOWSAFE1ref   5.0598508 1.05109756  24.3574824
## SDHFOODref    5.7018528 1.39667442  23.2775260
## SDHMEALSref   0.1551266 0.02445665   0.9839562
## SDHMONEYref   0.3658059 0.09863006   1.3567258
## SDHSTRESref   0.1064052 0.02004264   0.5648985
## GENHLTHref    0.9225879 0.23615444   3.6042870
## PHYSHLTHref   1.6851689 0.35063392   8.0990287
## MENTHLTHref   2.1786350 0.47037511  10.0907776
## POORHLTHref  18.4108717 2.53315948 133.8092599
## SMOKDAY2ref   2.1106337 0.55569655   8.0165598
## ECIGNOWref    0.5560824 0.09477437   3.2627771
## CVDSTRK3ref   2.2878414 0.20891081  25.0547982
## CVDCRHD4ref   5.4290260 0.19484415 151.2712781
## DIABETE3ref   1.0625045 0.17916369   6.3010300
## ADDEPEV2ref   0.4676258 0.13110607   1.6679157
## HAVARTH3ref   0.5868454 0.14762242   2.3328946
## CHCCOPD1ref   1.8165263 0.21378872  15.4347136
## DEAFref       0.3891210 0.05920097   2.5576469
## BLINDref      0.1219908 0.02616881   0.5686833
## DECIDEref     3.0494125 0.80652280  11.5296387
## DIFFWALKref   4.1703739 0.62312824  27.9108166
## DIFFDRESref   4.9676887 0.82669092  29.8514599
## DIFFALONref   0.4810071 0.07332214   3.1554976
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 2.42 1.28 4.56 SEX 1.54 0.36 6.62
MARITALref 2.54 1.27 5.07 MARITAL 0.67 0.19 2.44
EDUCAref 1.17 0.59 2.32 EDUCA 1.15 0.39 3.37
EMPLOY1ref 2.17 1.15 4.07 EMPLOY1 0.76 0.23 2.55
INCOME2ref 1.12 0.47 2.72 INCOME2 1.39 0.32 6.08
X_BMI5CATref 0.98 0.48 1.98 X_BMI5CAT 1.60 0.46 5.57
X_AGEG5YRref 0.36 0.14 0.92 X_AGEG5YR 2.35 0.16 33.66
CHILDRENref 0.82 0.44 1.53 CHILDREN 0.30 0.10 0.97
SDHBILLSref 0.39 0.19 0.78 SDHBILLS 3.05 0.59 15.80
HOWSAFE1ref 1.55 0.57 4.25 HOWSAFE1 5.06 1.05 24.36
SDHFOODref 0.49 0.26 0.94 SDHFOOD 5.70 1.40 23.28
SDHMEALSref 0.36 0.19 0.68 SDHMEALS 0.16 0.02 0.98
SDHMONEYref 0.49 0.25 0.98 SDHMONEY 0.37 0.10 1.36
SDHSTRESref 0.09 0.04 0.19 SDHSTRES 0.11 0.02 0.56
GENHLTHref 0.16 0.08 0.33 GENHLTH 0.92 0.24 3.60
PHYSHLTHref 9.45 4.18 21.35 PHYSHLTH 1.69 0.35 8.10
MENTHLTHref 6.96 3.26 14.86 MENTHLTH 2.18 0.47 10.09
POORHLTHref 8.93 3.46 23.09 POORHLTH 18.41 2.53 133.81
SMOKDAY2ref 0.52 0.26 1.04 SMOKDAY2 2.11 0.56 8.02
ECIGNOWref 1.42 0.38 5.34 ECIGNOW 0.56 0.09 3.26
CVDSTRK3ref 0.37 0.09 1.49 CVDSTRK3 2.29 0.21 25.05
CVDCRHD4ref 1.10 0.24 4.96 CVDCRHD4 5.43 0.19 151.27
DIABETE3ref 1.17 0.46 2.94 DIABETE3 1.06 0.18 6.30
ADDEPEV2ref 0.15 0.07 0.31 ADDEPEV2 0.47 0.13 1.67
HAVARTH3ref 0.38 0.18 0.79 HAVARTH3 0.59 0.15 2.33
CHCCOPD1ref 0.28 0.09 0.85 CHCCOPD1 1.82 0.21 15.43
DEAFref 0.18 0.05 0.64 DEAF 0.39 0.06 2.56
BLINDref 0.47 0.19 1.15 BLIND 0.12 0.03 0.57
DECIDEref 0.19 0.09 0.39 DECIDE 3.05 0.81 11.53
DIFFWALKref 0.37 0.18 0.77 DIFFWALK 4.17 0.62 27.91
DIFFDRESref 0.34 0.12 0.99 DIFFDRES 4.97 0.83 29.85
DIFFALONref 0.11 0.04 0.28 DIFFALON 0.48 0.07 3.16
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR
ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

#Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

SLEPTIM1 - Hours per sleep at night

#Binomial logistic regression for each variable
or<-svyglm(SLEPTIM1~SEX, family=quasibinomial,design=svydesAA)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat

or <- svyglm(SLEPTIM1~ MARITAL, family = quasibinomial, design = svydesAA)
b <- or_fun("MARITAL")

or <- svyglm(SLEPTIM1~ EDUCA, family = quasibinomial, design = svydesAA)
c <- or_fun("EDUCA")

or <- svyglm(SLEPTIM1~ EMPLOY1, family = quasibinomial, design = svydesAA)
d <- or_fun("EMPLOY1")

or <- svyglm(SLEPTIM1~ INCOME2, family = quasibinomial, design = svydesAA)
e <- or_fun("INCOME2")

or <- svyglm(SLEPTIM1~ X_BMI5CAT, family = quasibinomial, design = svydesAA)
f <- or_fun("X_BMI5CAT")

or <- svyglm(SLEPTIM1~ X_AGEG5YR, family = quasibinomial, design = svydesAA)
h <- or_fun("X_AGEG5YR")

or <- svyglm(SLEPTIM1~ CHILDREN, family = quasibinomial, design = svydesAA)
i <- or_fun("CHILDREN")

or <- svyglm(SLEPTIM1~ SDHBILLS, family = quasibinomial, design = svydesAA)
j <- or_fun("SDHBILLS")

or <- svyglm(SLEPTIM1~ HOWSAFE1, family = quasibinomial, design = svydesAA)
k <- or_fun("HOWSAFE1")

or <- svyglm(SLEPTIM1~ SDHFOOD, family = quasibinomial, design = svydesAA)
l <- or_fun("SDHFOOD")

or <- svyglm(SLEPTIM1~ SDHMEALS, family = quasibinomial, design = svydesAA)
m <- or_fun("SDHMEALS")

or <- svyglm(SLEPTIM1~ SDHMONEY, family = quasibinomial, design = svydesAA)
n <- or_fun("SDHMONEY")

or <- svyglm(SLEPTIM1~ SDHSTRES, family = quasibinomial, design = svydesAA)
o <- or_fun("SDHSTRES")

or <- svyglm(SLEPTIM1~ GENHLTH, family = quasibinomial, design = svydesAA)
p <- or_fun("GENHLTH")

or <- svyglm(SLEPTIM1~ PHYSHLTH, family = quasibinomial, design = svydesAA)
q <- or_fun("PHYSHLTH")

or <- svyglm(SLEPTIM1~ MENTHLTH, family = quasibinomial, design = svydesAA)
r <- or_fun("MENTHLTH")

or <- svyglm(SLEPTIM1~ POORHLTH, family = quasibinomial, design = svydesAA)
s <- or_fun("POORHLTH")

or <- svyglm(SLEPTIM1~ SMOKDAY2, family = quasibinomial, design = svydesAA)
t <- or_fun("SMOKDAY2")

or <- svyglm(SLEPTIM1~ ECIGNOW, family = quasibinomial, design = svydesAA)
u <- or_fun("ECIGNOW")

or <- svyglm(SLEPTIM1~ CVDSTRK3, family = quasibinomial, design = svydesAA)
v <- or_fun("CVDSTRK3")

or <- svyglm(SLEPTIM1~ CVDCRHD4, family = quasibinomial, design = svydesAA)
w <- or_fun("CVDCRHD4")

or <- svyglm(SLEPTIM1~ DIABETE3, family = quasibinomial, design = svydesAA)
x <- or_fun("DIABETE3")

or <- svyglm(SLEPTIM1~ ADDEPEV2, family = quasibinomial, design = svydesAA)
y <- or_fun("ADDEPEV2")

or <- svyglm(SLEPTIM1~ HAVARTH3, family = quasibinomial, design = svydesAA)
z <- or_fun("HAVARTH3")

or <- svyglm(SLEPTIM1~ CHCCOPD1, family = quasibinomial, design = svydesAA)
aa <- or_fun("CHCCOPD1")

or <- svyglm(SLEPTIM1~ DEAF, family = quasibinomial, design = svydesAA)
bb <- or_fun("DEAF")

or <- svyglm(SLEPTIM1~ BLIND, family = quasibinomial, design = svydesAA)
cc <- or_fun("BLIND")

or <- svyglm(SLEPTIM1~ DECIDE, family = quasibinomial, design = svydesAA)
dd <- or_fun("DECIDE")

or <- svyglm(SLEPTIM1~ DIFFWALK, family = quasibinomial, design = svydesAA)
ee <- or_fun("DIFFWALK")

or <- svyglm(SLEPTIM1~ DIFFDRES, family = quasibinomial, design = svydesAA)
ff <- or_fun("DIFFDRES")

or <- svyglm(SLEPTIM1~ DIFFALON, family = quasibinomial, design = svydesAA)
gg <- or_fun("DIFFALON")



# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 +
                X_BMI5CAT  + X_AGEG5YR + CHILDREN  + SDHBILLS + 
                HOWSAFE1 + SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + 
                PHYSHLTH + MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW +
                CVDSTRK3 +  CVDCRHD4 + DIABETE3 + ADDEPEV2 + HAVARTH3 + 
                CHCCOPD1 + DEAF + BLIND + DECIDE + DIFFWALK + DIFFDRES +
                DIFFALON, family = quasibinomial, design = svydesAA)

summary(alr)
## 
## Call:
## svyglm(formula = SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_AGEG5YR + CHILDREN + SDHBILLS + HOWSAFE1 + 
##     SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + 
##     MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + CVDCRHD4 + 
##     DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + 
##     DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydesAA, 
##     family = quasibinomial)
## 
## Survey design:
## subset(svydes, RACE == "Black only, non-Hispanic")
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  -0.62742    0.90683  -0.692   0.4900  
## SEXref       -0.20130    0.49023  -0.411   0.6819  
## MARITALref   -0.23568    0.48871  -0.482   0.6303  
## EDUCAref      0.45842    0.46931   0.977   0.3302  
## EMPLOY1ref    0.13554    0.43661   0.310   0.7566  
## INCOME2ref   -0.42123    0.76287  -0.552   0.5816  
## X_BMI5CATref  0.20938    0.43897   0.477   0.6341  
## X_AGEG5YRref -2.03222    0.83837  -2.424   0.0165 *
## CHILDRENref   0.59703    0.46920   1.272   0.2051  
## SDHBILLSref  -0.07563    0.60316  -0.125   0.9004  
## HOWSAFE1ref  -0.18871    0.71208  -0.265   0.7913  
## SDHFOODref    0.13073    0.62349   0.210   0.8342  
## SDHMEALSref   0.46633    0.68921   0.677   0.4997  
## SDHMONEYref   0.88944    0.51011   1.744   0.0832 .
## SDHSTRESref  -0.87431    0.65981  -1.325   0.1871  
## GENHLTHref   -0.54989    0.52878  -1.040   0.3000  
## PHYSHLTHref  -1.00914    0.63925  -1.579   0.1164  
## MENTHLTHref   0.25294    0.60193   0.420   0.6749  
## POORHLTHref   0.02806    0.63465   0.044   0.9648  
## SMOKDAY2ref   0.24493    0.48012   0.510   0.6107  
## ECIGNOWref    0.28705    1.03603   0.277   0.7821  
## CVDSTRK3ref   0.18916    0.88087   0.215   0.8302  
## CVDCRHD4ref  -0.13472    1.10345  -0.122   0.9030  
## DIABETE3ref  -0.91694    0.70020  -1.310   0.1923  
## ADDEPEV2ref  -0.85519    0.61957  -1.380   0.1695  
## HAVARTH3ref  -0.13938    0.58886  -0.237   0.8132  
## CHCCOPD1ref   1.31833    0.78257   1.685   0.0941 .
## DEAFref      -1.41685    0.99942  -1.418   0.1583  
## BLINDref     -0.29090    0.73501  -0.396   0.6928  
## DECIDEref     0.55292    0.59251   0.933   0.3522  
## DIFFWALKref  -0.02382    0.59344  -0.040   0.9680  
## DIFFDRESref  -0.16828    0.79104  -0.213   0.8318  
## DIFFALONref   0.42188    0.86288   0.489   0.6256  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 0.9916475)
## 
## Number of Fisher Scoring iterations: 5
confint(alr)
##                   2.5 %     97.5 %
## (Intercept)  -2.4047672  1.1499266
## SEXref       -1.1621402  0.7595395
## MARITALref   -1.1935435  0.7221793
## EDUCAref     -0.4614196  1.3782519
## EMPLOY1ref   -0.7202046  0.9912854
## INCOME2ref   -1.9164255  1.0739585
## X_BMI5CATref -0.6509900  1.0697412
## X_AGEG5YRref -3.6753920 -0.3890556
## CHILDRENref  -0.3225854  1.5166404
## SDHBILLSref  -1.2577929  1.1065343
## HOWSAFE1ref  -1.5843556  1.2069308
## SDHFOODref   -1.0912911  1.3527610
## SDHMEALSref  -0.8845012  1.8171547
## SDHMONEYref  -0.1103658  1.8892369
## SDHSTRESref  -2.1675148  0.4188932
## GENHLTHref   -1.5862819  0.4864941
## PHYSHLTHref  -2.2620353  0.2437600
## MENTHLTHref  -0.9268279  1.4326992
## POORHLTHref  -1.2158312  1.2719467
## SMOKDAY2ref  -0.6960900  1.1859417
## ECIGNOWref   -1.7435352  2.3176414
## CVDSTRK3ref  -1.5373195  1.9156442
## CVDCRHD4ref  -2.2974362  2.0279976
## DIABETE3ref  -2.2893055  0.4554217
## ADDEPEV2ref  -2.0695211  0.3591419
## HAVARTH3ref  -1.2935248  1.0147741
## CHCCOPD1ref  -0.2154827  2.8521344
## DEAFref      -3.3756745  0.5419682
## BLINDref     -1.7314932  1.1496864
## DECIDEref    -0.6083741  1.7142057
## DIFFWALKref  -1.1869441  1.1393136
## DIFFDRESref  -1.7186805  1.3821237
## DIFFALONref  -1.2693386  2.1131084
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    0.5339675    0.8176668    0.7900318    1.5815670    1.1451555    0.6562369 
## X_BMI5CATref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref   SDHFOODref 
##    1.2329080    0.1310438    1.8167106    0.9271598    0.8280246    1.1396657 
##  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref  MENTHLTHref 
##    1.5941278    2.4337555    0.4171494    0.5770110    0.3645332    1.2878004 
##  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref  DIABETE3ref 
##    1.0284551    1.2775266    1.3324949    1.2082371    0.8739612    0.3997396 
##  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref    DECIDEref 
##    0.4252026    0.8699014    3.7371597    0.2424758    0.7475879    1.7383142 
##  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    0.9764661    0.8451186    1.5248330
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR      2.5 %     97.5 %
## (Intercept)  0.5339675 0.09028651  3.1579610
## SEXref       0.8176668 0.31281597  2.1372917
## MARITALref   0.7900318 0.30314518  2.0589153
## EDUCAref     1.5815670 0.63038808  3.9679592
## EMPLOY1ref   1.1451555 0.48665266  2.6946961
## INCOME2ref   0.6562369 0.14713194  2.9269430
## X_BMI5CATref 1.2329080 0.52152923  2.9146251
## X_AGEG5YRref 0.1310438 0.02533947  0.6776966
## CHILDRENref  1.8167106 0.72427408  4.5568902
## SDHBILLSref  0.9271598 0.28428078  3.0238603
## HOWSAFE1ref  0.8280246 0.20507990  3.3432079
## SDHFOODref   1.1396657 0.33578270  3.8680907
## SDHMEALSref  1.5941278 0.41292010  6.1543225
## SDHMONEYref  2.4337555 0.89550650  6.6143192
## SDHSTRESref  0.4171494 0.11446172  1.5202780
## GENHLTHref   0.5770110 0.20468524  1.6266034
## PHYSHLTHref  0.3645332 0.10413832  1.2760380
## MENTHLTHref  1.2878004 0.39580726  4.1899935
## POORHLTHref  1.0284551 0.29646349  3.5677913
## SMOKDAY2ref  1.2775266 0.49853075  3.2737684
## ECIGNOWref   1.3324949 0.17490099 10.1517020
## CVDSTRK3ref  1.2082371 0.21495651  6.7913123
## CVDCRHD4ref  0.8739612 0.10051622  7.5988548
## DIABETE3ref  0.3997396 0.10133682  1.5768381
## ADDEPEV2ref  0.4252026 0.12624623  1.4321001
## HAVARTH3ref  0.8699014 0.27430220  2.7587400
## CHCCOPD1ref  3.7371597 0.80615223 17.3247208
## DEAFref      0.2424758 0.03419504  1.7193876
## BLINDref     0.7475879 0.17701989  3.1572027
## DECIDEref    1.7383142 0.54423500  5.5522635
## DIFFWALKref  0.9764661 0.30515236  3.1246230
## DIFFDRESref  0.8451186 0.17930259  3.9833522
## DIFFALONref  1.5248330 0.28101742  8.2739196
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR      2.5 %     97.5 %
## SEXref       0.8176668 0.31281597  2.1372917
## MARITALref   0.7900318 0.30314518  2.0589153
## EDUCAref     1.5815670 0.63038808  3.9679592
## EMPLOY1ref   1.1451555 0.48665266  2.6946961
## INCOME2ref   0.6562369 0.14713194  2.9269430
## X_BMI5CATref 1.2329080 0.52152923  2.9146251
## X_AGEG5YRref 0.1310438 0.02533947  0.6776966
## CHILDRENref  1.8167106 0.72427408  4.5568902
## SDHBILLSref  0.9271598 0.28428078  3.0238603
## HOWSAFE1ref  0.8280246 0.20507990  3.3432079
## SDHFOODref   1.1396657 0.33578270  3.8680907
## SDHMEALSref  1.5941278 0.41292010  6.1543225
## SDHMONEYref  2.4337555 0.89550650  6.6143192
## SDHSTRESref  0.4171494 0.11446172  1.5202780
## GENHLTHref   0.5770110 0.20468524  1.6266034
## PHYSHLTHref  0.3645332 0.10413832  1.2760380
## MENTHLTHref  1.2878004 0.39580726  4.1899935
## POORHLTHref  1.0284551 0.29646349  3.5677913
## SMOKDAY2ref  1.2775266 0.49853075  3.2737684
## ECIGNOWref   1.3324949 0.17490099 10.1517020
## CVDSTRK3ref  1.2082371 0.21495651  6.7913123
## CVDCRHD4ref  0.8739612 0.10051622  7.5988548
## DIABETE3ref  0.3997396 0.10133682  1.5768381
## ADDEPEV2ref  0.4252026 0.12624623  1.4321001
## HAVARTH3ref  0.8699014 0.27430220  2.7587400
## CHCCOPD1ref  3.7371597 0.80615223 17.3247208
## DEAFref      0.2424758 0.03419504  1.7193876
## BLINDref     0.7475879 0.17701989  3.1572027
## DECIDEref    1.7383142 0.54423500  5.5522635
## DIFFWALKref  0.9764661 0.30515236  3.1246230
## DIFFDRESref  0.8451186 0.17930259  3.9833522
## DIFFALONref  1.5248330 0.28101742  8.2739196
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 0.95 0.61 1.48 SEX 0.82 0.31 2.14
MARITALref 1.97 1.25 3.09 MARITAL 0.79 0.30 2.06
EDUCAref 1.00 0.62 1.60 EDUCA 1.58 0.63 3.97
EMPLOY1ref 1.25 0.80 1.94 EMPLOY1 1.15 0.49 2.69
INCOME2ref 1.13 0.60 2.11 INCOME2 0.66 0.15 2.93
X_BMI5CATref 1.11 0.68 1.82 X_BMI5CAT 1.23 0.52 2.91
X_AGEG5YRref 0.23 0.10 0.53 X_AGEG5YR 0.13 0.03 0.68
CHILDRENref 0.94 0.61 1.46 CHILDREN 1.82 0.72 4.56
SDHBILLSref 1.35 0.73 2.47 SDHBILLS 0.93 0.28 3.02
HOWSAFE1ref 1.19 0.49 2.87 HOWSAFE1 0.83 0.21 3.34
SDHFOODref 1.42 0.85 2.37 SDHFOOD 1.14 0.34 3.87
SDHMEALSref 1.33 0.80 2.22 SDHMEALS 1.59 0.41 6.15
SDHMONEYref 1.68 1.08 2.63 SDHMONEY 2.43 0.90 6.61
SDHSTRESref 0.50 0.23 1.08 SDHSTRES 0.42 0.11 1.52
GENHLTHref 0.67 0.37 1.24 GENHLTH 0.58 0.20 1.63
PHYSHLTHref 0.94 0.47 1.90 PHYSHLTH 0.36 0.10 1.28
MENTHLTHref 1.95 0.96 3.98 MENTHLTH 1.29 0.40 4.19
POORHLTHref 0.96 0.42 2.17 POORHLTH 1.03 0.30 3.57
SMOKDAY2ref 0.89 0.50 1.56 SMOKDAY2 1.28 0.50 3.27
ECIGNOWref 1.27 0.43 3.74 ECIGNOW 1.33 0.17 10.15
CVDSTRK3ref 0.53 0.14 1.90 CVDSTRK3 1.21 0.21 6.79
CVDCRHD4ref 0.73 0.18 3.00 CVDCRHD4 0.87 0.10 7.60
DIABETE3ref 0.73 0.32 1.68 DIABETE3 0.40 0.10 1.58
ADDEPEV2ref 0.45 0.23 0.89 ADDEPEV2 0.43 0.13 1.43
HAVARTH3ref 0.85 0.45 1.62 HAVARTH3 0.87 0.27 2.76
CHCCOPD1ref 1.46 0.54 3.95 CHCCOPD1 3.74 0.81 17.32
DEAFref 0.30 0.08 1.04 DEAF 0.24 0.03 1.72
BLINDref 1.14 0.48 2.71 BLIND 0.75 0.18 3.16
DECIDEref 0.73 0.37 1.42 DECIDE 1.74 0.54 5.55
DIFFWALKref 0.95 0.50 1.80 DIFFWALK 0.98 0.31 3.12
DIFFDRESref 0.77 0.28 2.14 DIFFDRES 0.85 0.18 3.98
DIFFALONref 0.62 0.25 1.57 DIFFALON 1.52 0.28 8.27
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR
ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

# Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) +
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

White

ADSLEEP - Difficulty sleeping past 14 days

svydesW<-subset(svydes,RACE == "White only, non-Hispanic")

#Binomial logistic regression for each variable
or<-svyglm(ADSLEEP~SEX, family=quasibinomial,design=svydesW)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat
or <- svyglm(ADSLEEP~ MARITAL, family = quasibinomial, design = svydesW)
b <- or_fun("MARITAL")

or <- svyglm(ADSLEEP~ EDUCA, family = quasibinomial, design = svydesW)
c <- or_fun("EDUCA")

or <- svyglm(ADSLEEP~ EMPLOY1, family = quasibinomial, design = svydesW)
d <- or_fun("EMPLOY1")

or <- svyglm(ADSLEEP~ INCOME2, family = quasibinomial, design = svydesW)
e <- or_fun("INCOME2")

or <- svyglm(ADSLEEP~ X_BMI5CAT, family = quasibinomial, design = svydesW)
f <- or_fun("X_BMI5CAT")

or <- svyglm(ADSLEEP~ X_AGEG5YR, family = quasibinomial, design = svydesW)
h <- or_fun("X_AGEG5YR")

or <- svyglm(ADSLEEP~ CHILDREN, family = quasibinomial, design = svydesW)
i <- or_fun("CHILDREN")

or <- svyglm(ADSLEEP~ SDHBILLS, family = quasibinomial, design = svydesW)
j <- or_fun("SDHBILLS")

or <- svyglm(ADSLEEP~ HOWSAFE1, family = quasibinomial, design = svydesW)
k <- or_fun("HOWSAFE1")

or <- svyglm(ADSLEEP~ SDHFOOD, family = quasibinomial, design = svydesW)
l <- or_fun("SDHFOOD")

or <- svyglm(ADSLEEP~ SDHMEALS, family = quasibinomial, design = svydesW)
m <- or_fun("SDHMEALS")

or <- svyglm(ADSLEEP~ SDHMONEY, family = quasibinomial, design = svydesW)
n <- or_fun("SDHMONEY")

or <- svyglm(ADSLEEP~ SDHSTRES, family = quasibinomial, design = svydesW)
o <- or_fun("SDHSTRES")

or <- svyglm(ADSLEEP~ GENHLTH, family = quasibinomial, design = svydesW)
p <- or_fun("GENHLTH")

or <- svyglm(ADSLEEP~ PHYSHLTH, family = quasibinomial, design = svydesW)
q <- or_fun("PHYSHLTH")

or <- svyglm(ADSLEEP~ MENTHLTH, family = quasibinomial, design = svydesW)
r <- or_fun("MENTHLTH")

or <- svyglm(ADSLEEP~ POORHLTH, family = quasibinomial, design = svydesW)
s <- or_fun("POORHLTH")

or <- svyglm(ADSLEEP~ SMOKDAY2, family = quasibinomial, design = svydesW)
t <- or_fun("SMOKDAY2")

or <- svyglm(ADSLEEP~ ECIGNOW, family = quasibinomial, design = svydesW)
u <- or_fun("ECIGNOW")

or <- svyglm(ADSLEEP~ CVDSTRK3, family = quasibinomial, design = svydesW)
v <- or_fun("CVDSTRK3")

or <- svyglm(ADSLEEP~ CVDCRHD4, family = quasibinomial, design = svydesW)
w <- or_fun("CVDCRHD4")

or <- svyglm(ADSLEEP~ DIABETE3, family = quasibinomial, design = svydesW)
x <- or_fun("DIABETE3")

or <- svyglm(ADSLEEP~ ADDEPEV2, family = quasibinomial, design = svydesW)
y <- or_fun("ADDEPEV2")

or <- svyglm(ADSLEEP~ HAVARTH3, family = quasibinomial, design = svydesW)
z <- or_fun("HAVARTH3")

or <- svyglm(ADSLEEP~ CHCCOPD1, family = quasibinomial, design = svydesW)
aa <- or_fun("CHCCOPD1")

or <- svyglm(ADSLEEP~ DEAF, family = quasibinomial, design = svydesW)
bb <- or_fun("DEAF")

or <- svyglm(ADSLEEP~ BLIND, family = quasibinomial, design = svydesW)
cc <- or_fun("BLIND")

or <- svyglm(ADSLEEP~ DECIDE, family = quasibinomial, design = svydesW)
dd <- or_fun("DECIDE")

or <- svyglm(ADSLEEP~ DIFFWALK, family = quasibinomial, design = svydesW)
ee <- or_fun("DIFFWALK")

or <- svyglm(ADSLEEP~ DIFFDRES, family = quasibinomial, design = svydesW)
ff <- or_fun("DIFFDRES")

or <- svyglm(ADSLEEP~ DIFFALON, family = quasibinomial, design = svydesW)
gg <- or_fun("DIFFALON")



# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f,h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 + X_BMI5CAT
               + X_AGEG5YR + CHILDREN  + SDHBILLS + HOWSAFE1 + SDHFOOD + 
                SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + MENTHLTH + 
                POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 +  CVDCRHD4 + DIABETE3 + 
                ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + DECIDE + 
                DIFFWALK + DIFFDRES + DIFFALON, family = quasibinomial, 
              design = svydesW)

summary(alr)
## 
## Call:
## svyglm(formula = ADSLEEP ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_AGEG5YR + CHILDREN + SDHBILLS + HOWSAFE1 + 
##     SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + 
##     MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + CVDCRHD4 + 
##     DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + 
##     DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydesW, 
##     family = quasibinomial)
## 
## Survey design:
## subset(svydes, RACE == "White only, non-Hispanic")
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.029806   0.202191   5.093 3.63e-07 ***
## SEXref        0.155904   0.086069   1.811 0.070131 .  
## MARITALref   -0.015277   0.085356  -0.179 0.857963    
## EDUCAref     -0.192942   0.093910  -2.055 0.039967 *  
## EMPLOY1ref   -0.091723   0.090886  -1.009 0.312910    
## INCOME2ref    0.007006   0.117050   0.060 0.952274    
## X_BMI5CATref  0.197275   0.094766   2.082 0.037411 *  
## X_AGEG5YRref -0.080365   0.127179  -0.632 0.527471    
## CHILDRENref  -0.067428   0.097282  -0.693 0.488266    
## SDHBILLSref  -0.258732   0.168803  -1.533 0.125389    
## HOWSAFE1ref   0.059096   0.255823   0.231 0.817319    
## SDHFOODref   -0.107492   0.156874  -0.685 0.493236    
## SDHMEALSref  -0.199265   0.135536  -1.470 0.141559    
## SDHMONEYref   0.096672   0.092586   1.044 0.296465    
## SDHSTRESref  -1.142877   0.122262  -9.348  < 2e-16 ***
## GENHLTHref   -0.370999   0.111057  -3.341 0.000841 ***
## PHYSHLTHref   0.401980   0.110949   3.623 0.000293 ***
## MENTHLTHref   0.350342   0.113853   3.077 0.002099 ** 
## POORHLTHref   0.087465   0.133658   0.654 0.512884    
## SMOKDAY2ref  -0.063023   0.122781  -0.513 0.607764    
## ECIGNOWref   -0.197395   0.204339  -0.966 0.334075    
## CVDSTRK3ref   0.273279   0.214554   1.274 0.202815    
## CVDCRHD4ref   0.249225   0.166348   1.498 0.134129    
## DIABETE3ref  -0.064444   0.125948  -0.512 0.608901    
## ADDEPEV2ref  -0.430179   0.094681  -4.543 5.64e-06 ***
## HAVARTH3ref  -0.181831   0.090980  -1.999 0.045698 *  
## CHCCOPD1ref  -0.042012   0.154690  -0.272 0.785949    
## DEAFref      -0.199872   0.138532  -1.443 0.149131    
## BLINDref      0.045269   0.191497   0.236 0.813135    
## DECIDEref    -0.509417   0.124774  -4.083 4.51e-05 ***
## DIFFWALKref  -0.088769   0.122289  -0.726 0.467929    
## DIFFDRESref  -0.254140   0.190235  -1.336 0.181623    
## DIFFALONref  -0.108623   0.159349  -0.682 0.495474    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 1.028312)
## 
## Number of Fisher Scoring iterations: 4
confint(alr)
##                    2.5 %       97.5 %
## (Intercept)   0.63351982  1.426092049
## SEXref       -0.01278870  0.324596656
## MARITALref   -0.18257200  0.152018617
## EDUCAref     -0.37700257 -0.008880921
## EMPLOY1ref   -0.26985610  0.086409173
## INCOME2ref   -0.22240763  0.236419455
## X_BMI5CATref  0.01153696  0.383013356
## X_AGEG5YRref -0.32963134  0.168900813
## CHILDRENref  -0.25809776  0.123242571
## SDHBILLSref  -0.58957883  0.072114850
## HOWSAFE1ref  -0.44230819  0.560501137
## SDHFOODref   -0.41496040  0.199975788
## SDHMEALSref  -0.46491110  0.066380674
## SDHMONEYref  -0.08479312  0.278137306
## SDHSTRESref  -1.38250681 -0.903247870
## GENHLTHref   -0.58866699 -0.153331945
## PHYSHLTHref   0.18452354  0.619436369
## MENTHLTHref   0.12719481  0.573488570
## POORHLTHref  -0.17449996  0.349429371
## SMOKDAY2ref  -0.30366919  0.177623687
## ECIGNOWref   -0.59789231  0.203102852
## CVDSTRK3ref  -0.14723895  0.693797569
## CVDCRHD4ref  -0.07681153  0.575262515
## DIABETE3ref  -0.31129839  0.182410472
## ADDEPEV2ref  -0.61575126 -0.244607410
## HAVARTH3ref  -0.36014879 -0.003513027
## CHCCOPD1ref  -0.34519955  0.261175735
## DEAFref      -0.47138911  0.071645073
## BLINDref     -0.33005927  0.420596625
## DECIDEref    -0.75397027 -0.264863270
## DIFFWALKref  -0.32845048  0.150912296
## DIFFDRESref  -0.62699314  0.118714048
## DIFFALONref  -0.42094207  0.203695372
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    2.8005223    1.1687140    0.9848394    0.8245300    0.9123574    1.0070305 
## X_BMI5CATref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref   SDHFOODref 
##    1.2180792    0.9227792    0.9347954    0.7720299    1.0608776    0.8980834 
##  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref  MENTHLTHref 
##    0.8193326    1.1014991    0.3189001    0.6900443    1.4947814    1.4195525 
##  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref  DIABETE3ref 
##    1.0914037    0.9389221    0.8208666    1.3142673    1.2830313    0.9375887 
##  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref    DECIDEref 
##    0.6503924    0.8337423    0.9588584    0.8188355    1.0463089    0.6008459 
##  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    0.9150568    0.7755836    0.8970682
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR     2.5 %    97.5 %
## (Intercept)  2.8005223 1.8842311 4.1624009
## SEXref       1.1687140 0.9872927 1.3834725
## MARITALref   0.9848394 0.8331247 1.1641819
## EDUCAref     0.8245300 0.6859143 0.9911584
## EMPLOY1ref   0.9123574 0.7634894 1.0902523
## INCOME2ref   1.0070305 0.8005890 1.2667055
## X_BMI5CATref 1.2180792 1.0116038 1.4666976
## X_AGEG5YRref 0.9227792 0.7191888 1.1840027
## CHILDRENref  0.9347954 0.7725197 1.1311588
## SDHBILLSref  0.7720299 0.5545608 1.0747788
## HOWSAFE1ref  1.0608776 0.6425516 1.7515500
## SDHFOODref   0.8980834 0.6603664 1.2213732
## SDHMEALSref  0.8193326 0.6281909 1.0686334
## SDHMONEYref  1.1014991 0.9187023 1.3206675
## SDHSTRESref  0.3189001 0.2509487 0.4052513
## GENHLTHref   0.6900443 0.5550667 0.8578449
## PHYSHLTHref  1.4947814 1.2026453 1.8578806
## MENTHLTHref  1.4195525 1.1356382 1.7744465
## POORHLTHref  1.0914037 0.8398769 1.4182580
## SMOKDAY2ref  0.9389221 0.7381050 1.1943758
## ECIGNOWref   0.8208666 0.5499696 1.2251985
## CVDSTRK3ref  1.3142673 0.8630877 2.0013012
## CVDCRHD4ref  1.2830313 0.9260644 1.7775971
## DIABETE3ref  0.9375887 0.7324953 1.2001067
## ADDEPEV2ref  0.6503924 0.5402349 0.7830119
## HAVARTH3ref  0.8337423 0.6975725 0.9964931
## CHCCOPD1ref  0.9588584 0.7080790 1.2984558
## DEAFref      0.8188355 0.6241347 1.0742740
## BLINDref     1.0463089 0.7188811 1.5228699
## DECIDEref    0.6008459 0.4704948 0.7673109
## DIFFWALKref  0.9150568 0.7200386 1.1628947
## DIFFDRESref  0.7755836 0.5341956 1.1260479
## DIFFALONref  0.8970682 0.6564281 1.2259246
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR     2.5 %    97.5 %
## SEXref       1.1687140 0.9872927 1.3834725
## MARITALref   0.9848394 0.8331247 1.1641819
## EDUCAref     0.8245300 0.6859143 0.9911584
## EMPLOY1ref   0.9123574 0.7634894 1.0902523
## INCOME2ref   1.0070305 0.8005890 1.2667055
## X_BMI5CATref 1.2180792 1.0116038 1.4666976
## X_AGEG5YRref 0.9227792 0.7191888 1.1840027
## CHILDRENref  0.9347954 0.7725197 1.1311588
## SDHBILLSref  0.7720299 0.5545608 1.0747788
## HOWSAFE1ref  1.0608776 0.6425516 1.7515500
## SDHFOODref   0.8980834 0.6603664 1.2213732
## SDHMEALSref  0.8193326 0.6281909 1.0686334
## SDHMONEYref  1.1014991 0.9187023 1.3206675
## SDHSTRESref  0.3189001 0.2509487 0.4052513
## GENHLTHref   0.6900443 0.5550667 0.8578449
## PHYSHLTHref  1.4947814 1.2026453 1.8578806
## MENTHLTHref  1.4195525 1.1356382 1.7744465
## POORHLTHref  1.0914037 0.8398769 1.4182580
## SMOKDAY2ref  0.9389221 0.7381050 1.1943758
## ECIGNOWref   0.8208666 0.5499696 1.2251985
## CVDSTRK3ref  1.3142673 0.8630877 2.0013012
## CVDCRHD4ref  1.2830313 0.9260644 1.7775971
## DIABETE3ref  0.9375887 0.7324953 1.2001067
## ADDEPEV2ref  0.6503924 0.5402349 0.7830119
## HAVARTH3ref  0.8337423 0.6975725 0.9964931
## CHCCOPD1ref  0.9588584 0.7080790 1.2984558
## DEAFref      0.8188355 0.6241347 1.0742740
## BLINDref     1.0463089 0.7188811 1.5228699
## DECIDEref    0.6008459 0.4704948 0.7673109
## DIFFWALKref  0.9150568 0.7200386 1.1628947
## DIFFDRESref  0.7755836 0.5341956 1.1260479
## DIFFALONref  0.8970682 0.6564281 1.2259246
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 1.42 1.27 1.59 SEX 1.17 0.99 1.38
MARITALref 1.47 1.32 1.65 MARITAL 0.98 0.83 1.16
EDUCAref 0.84 0.74 0.96 EDUCA 0.82 0.69 0.99
EMPLOY1ref 1.18 1.05 1.31 EMPLOY1 0.91 0.76 1.09
INCOME2ref 0.94 0.79 1.11 INCOME2 1.01 0.80 1.27
X_BMI5CATref 1.23 1.08 1.40 X_BMI5CAT 1.22 1.01 1.47
X_AGEG5YRref 0.96 0.81 1.15 X_AGEG5YR 0.92 0.72 1.18
CHILDRENref 0.85 0.74 0.96 CHILDREN 0.93 0.77 1.13
SDHBILLSref 0.27 0.22 0.33 SDHBILLS 0.77 0.55 1.07
HOWSAFE1ref 0.36 0.26 0.49 HOWSAFE1 1.06 0.64 1.75
SDHFOODref 0.32 0.27 0.38 SDHFOOD 0.90 0.66 1.22
SDHMEALSref 0.36 0.31 0.42 SDHMEALS 0.82 0.63 1.07
SDHMONEYref 0.54 0.48 0.60 SDHMONEY 1.10 0.92 1.32
SDHSTRESref 0.13 0.11 0.16 SDHSTRES 0.32 0.25 0.41
GENHLTHref 0.28 0.24 0.32 GENHLTH 0.69 0.56 0.86
PHYSHLTHref 3.78 3.27 4.36 PHYSHLTH 1.49 1.20 1.86
MENTHLTHref 5.01 4.26 5.89 MENTHLTH 1.42 1.14 1.77
POORHLTHref 3.43 2.85 4.12 POORHLTH 1.09 0.84 1.42
SMOKDAY2ref 0.55 0.47 0.64 SMOKDAY2 0.94 0.74 1.19
ECIGNOWref 0.56 0.42 0.74 ECIGNOW 0.82 0.55 1.23
CVDSTRK3ref 0.61 0.46 0.81 CVDSTRK3 1.31 0.86 2.00
CVDCRHD4ref 0.70 0.56 0.88 CVDCRHD4 1.28 0.93 1.78
DIABETE3ref 0.70 0.60 0.83 DIABETE3 0.94 0.73 1.20
ADDEPEV2ref 0.29 0.25 0.33 ADDEPEV2 0.65 0.54 0.78
HAVARTH3ref 0.51 0.45 0.57 HAVARTH3 0.83 0.70 1.00
CHCCOPD1ref 0.40 0.33 0.49 CHCCOPD1 0.96 0.71 1.30
DEAFref 0.59 0.49 0.71 DEAF 0.82 0.62 1.07
BLINDref 0.46 0.35 0.59 BLIND 1.05 0.72 1.52
DECIDEref 0.17 0.15 0.21 DECIDE 0.60 0.47 0.77
DIFFWALKref 0.33 0.29 0.38 DIFFWALK 0.92 0.72 1.16
DIFFDRESref 0.18 0.14 0.23 DIFFDRES 0.78 0.53 1.13
DIFFALONref 0.20 0.16 0.24 DIFFALON 0.90 0.66 1.23
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot
ggplot(table1, aes(x=hv, y = OR)) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_bar(stat = "identity", position = "dodge")

ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  theme(axis.text.x = element_text(angle = 90)) +  
  geom_abline(slope = 0, intercept = 1)

ggplot(table1, aes(x=hv, y = OR)) +
  geom_bar(stat = "identity", position = "dodge") +
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_abline(slope = 0, intercept = 1, color = "red")

ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))

SLEPTIM1 - Hours per sleep at night

#Binomial logistic regression for each variable
or<-svyglm(SLEPTIM1~SEX, family=quasibinomial,design=svydesW)
#OR saved for each variable
a <- or_fun("SEX")

#Repeat
or <- svyglm(SLEPTIM1~ MARITAL, family = quasibinomial, design = svydesW)
b <- or_fun("MARITAL")

or <- svyglm(SLEPTIM1~ EDUCA, family = quasibinomial, design = svydesW)
c <- or_fun("EDUCA")

or <- svyglm(SLEPTIM1~ EMPLOY1, family = quasibinomial, design = svydesW)
d <- or_fun("EMPLOY1")

or <- svyglm(SLEPTIM1~ INCOME2, family = quasibinomial, design = svydesW)
e <- or_fun("INCOME2")

or <- svyglm(SLEPTIM1~ X_BMI5CAT, family = quasibinomial, design = svydesW)
f <- or_fun("X_BMI5CAT")

or <- svyglm(SLEPTIM1~ X_AGEG5YR, family = quasibinomial, design = svydesW)
h <- or_fun("X_AGEG5YR")

or <- svyglm(SLEPTIM1~ CHILDREN, family = quasibinomial, design = svydesW)
i <- or_fun("CHILDREN")

or <- svyglm(SLEPTIM1~ SDHBILLS, family = quasibinomial, design = svydesW)
j <- or_fun("SDHBILLS")

or <- svyglm(SLEPTIM1~ HOWSAFE1, family = quasibinomial, design = svydesW)
k <- or_fun("HOWSAFE1")

or <- svyglm(SLEPTIM1~ SDHFOOD, family = quasibinomial, design = svydesW)
l <- or_fun("SDHFOOD")

or <- svyglm(SLEPTIM1~ SDHMEALS, family = quasibinomial, design = svydesW)
m <- or_fun("SDHMEALS")

or <- svyglm(SLEPTIM1~ SDHMONEY, family = quasibinomial, design = svydesW)
n <- or_fun("SDHMONEY")

or <- svyglm(SLEPTIM1~ SDHSTRES, family = quasibinomial, design = svydesW)
o <- or_fun("SDHSTRES")

or <- svyglm(SLEPTIM1~ GENHLTH, family = quasibinomial, design = svydesW)
p <- or_fun("GENHLTH")

or <- svyglm(SLEPTIM1~ PHYSHLTH, family = quasibinomial, design = svydesW)
q <- or_fun("PHYSHLTH")

or <- svyglm(SLEPTIM1~ MENTHLTH, family = quasibinomial, design = svydesW)
r <- or_fun("MENTHLTH")

or <- svyglm(SLEPTIM1~ POORHLTH, family = quasibinomial, design = svydesW)
s <- or_fun("POORHLTH")

or <- svyglm(SLEPTIM1~ SMOKDAY2, family = quasibinomial, design = svydesW)
t <- or_fun("SMOKDAY2")

or <- svyglm(SLEPTIM1~ ECIGNOW, family = quasibinomial, design = svydesW)
u <- or_fun("ECIGNOW")

or <- svyglm(SLEPTIM1~ CVDSTRK3, family = quasibinomial, design = svydesW)
v <- or_fun("CVDSTRK3")

or <- svyglm(SLEPTIM1~ CVDCRHD4, family = quasibinomial, design = svydesW)
w <- or_fun("CVDCRHD4")

or <- svyglm(SLEPTIM1~ DIABETE3, family = quasibinomial, design = svydesW)
x <- or_fun("DIABETE3")

or <- svyglm(SLEPTIM1~ ADDEPEV2, family = quasibinomial, design = svydesW)
y <- or_fun("ADDEPEV2")

or <- svyglm(SLEPTIM1~ HAVARTH3, family = quasibinomial, design = svydesW)
z <- or_fun("HAVARTH3")

or <- svyglm(SLEPTIM1~ CHCCOPD1, family = quasibinomial, design = svydesW)
aa <- or_fun("CHCCOPD1")

or <- svyglm(SLEPTIM1~ DEAF, family = quasibinomial, design = svydesW)
bb <- or_fun("DEAF")

or <- svyglm(SLEPTIM1~ BLIND, family = quasibinomial, design = svydesW)
cc <- or_fun("BLIND")

or <- svyglm(SLEPTIM1~ DECIDE, family = quasibinomial, design = svydesW)
dd <- or_fun("DECIDE")

or <- svyglm(SLEPTIM1~ DIFFWALK, family = quasibinomial, design = svydesW)
ee <- or_fun("DIFFWALK")

or <- svyglm(SLEPTIM1~ DIFFDRES, family = quasibinomial, design = svydesW)
ff <- or_fun("DIFFDRES")

or <- svyglm(SLEPTIM1~ DIFFALON, family = quasibinomial, design = svydesW)
gg <- or_fun("DIFFALON")


# Combine OR into 1 table
all_or <- bind_rows(a, b, c, d, e, f, h, i, j, k, l, m,n,o,p,
                    q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg)
all_or <- as.data.frame(all_or)


# Run all variables in logistic regression for adjusted OR
alr <- svyglm(SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + INCOME2 +
                X_BMI5CAT  + X_AGEG5YR + CHILDREN  + SDHBILLS + 
                HOWSAFE1 + SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + 
                PHYSHLTH + MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW +
                CVDSTRK3 +  CVDCRHD4 + DIABETE3 + ADDEPEV2 + HAVARTH3 + 
                CHCCOPD1 + DEAF + BLIND + DECIDE + DIFFWALK + DIFFDRES +
                DIFFALON, family = quasibinomial, design = svydesW)

summary(alr)
## 
## Call:
## svyglm(formula = SLEPTIM1 ~ SEX + MARITAL + EDUCA + EMPLOY1 + 
##     INCOME2 + X_BMI5CAT + X_AGEG5YR + CHILDREN + SDHBILLS + HOWSAFE1 + 
##     SDHFOOD + SDHMEALS + SDHMONEY + SDHSTRES + GENHLTH + PHYSHLTH + 
##     MENTHLTH + POORHLTH + SMOKDAY2 + ECIGNOW + CVDSTRK3 + CVDCRHD4 + 
##     DIABETE3 + ADDEPEV2 + HAVARTH3 + CHCCOPD1 + DEAF + BLIND + 
##     DECIDE + DIFFWALK + DIFFDRES + DIFFALON, design = svydesW, 
##     family = quasibinomial)
## 
## Survey design:
## subset(svydes, RACE == "White only, non-Hispanic")
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -0.281555   0.169994  -1.656 0.097714 .  
## SEXref       -0.088035   0.066159  -1.331 0.183348    
## MARITALref    0.257863   0.067377   3.827 0.000131 ***
## EDUCAref     -0.191481   0.076332  -2.509 0.012147 *  
## EMPLOY1ref   -0.176538   0.072062  -2.450 0.014318 *  
## INCOME2ref   -0.136601   0.096812  -1.411 0.158290    
## X_BMI5CATref  0.079353   0.074461   1.066 0.286602    
## X_AGEG5YRref -0.281058   0.103384  -2.719 0.006573 ** 
## CHILDRENref   0.484119   0.077826   6.221 5.24e-10 ***
## SDHBILLSref  -0.284643   0.145187  -1.961 0.049974 *  
## HOWSAFE1ref   0.092733   0.188987   0.491 0.623667    
## SDHFOODref    0.426491   0.144986   2.942 0.003276 ** 
## SDHMEALSref  -0.038634   0.125376  -0.308 0.757978    
## SDHMONEYref   0.388551   0.075886   5.120 3.13e-07 ***
## SDHSTRESref  -0.463598   0.115635  -4.009 6.16e-05 ***
## GENHLTHref   -0.361649   0.093233  -3.879 0.000106 ***
## PHYSHLTHref   0.042737   0.093390   0.458 0.647242    
## MENTHLTHref   0.257628   0.093495   2.756 0.005875 ** 
## POORHLTHref   0.202654   0.113224   1.790 0.073522 .  
## SMOKDAY2ref  -0.409506   0.096944  -4.224 2.43e-05 ***
## ECIGNOWref    0.173646   0.173027   1.004 0.315619    
## CVDSTRK3ref   0.135723   0.174706   0.777 0.437265    
## CVDCRHD4ref  -0.147531   0.138695  -1.064 0.287499    
## DIABETE3ref  -0.037566   0.104113  -0.361 0.718244    
## ADDEPEV2ref   0.061030   0.076254   0.800 0.423538    
## HAVARTH3ref  -0.143975   0.075834  -1.899 0.057666 .  
## CHCCOPD1ref  -0.250401   0.122433  -2.045 0.040872 *  
## DEAFref       0.007028   0.111291   0.063 0.949651    
## BLINDref     -0.254311   0.166054  -1.531 0.125692    
## DECIDEref    -0.316578   0.108778  -2.910 0.003622 ** 
## DIFFWALKref   0.139587   0.103975   1.343 0.179475    
## DIFFDRESref  -0.313138   0.158807  -1.972 0.048670 *  
## DIFFALONref  -0.233796   0.135851  -1.721 0.085300 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for quasibinomial family taken to be 1.039705)
## 
## Number of Fisher Scoring iterations: 4
confint(alr)
##                    2.5 %        97.5 %
## (Intercept)  -0.61473802  5.162788e-02
## SEXref       -0.21770400  4.163476e-02
## MARITALref    0.12580602  3.899204e-01
## EDUCAref     -0.34108972 -4.187245e-02
## EMPLOY1ref   -0.31777752 -3.529871e-02
## INCOME2ref   -0.32634832  5.314618e-02
## X_BMI5CATref -0.06658904  2.252942e-01
## X_AGEG5YRref -0.48368715 -7.842849e-02
## CHILDRENref   0.33158308  6.366541e-01
## SDHBILLSref  -0.56920485 -8.152809e-05
## HOWSAFE1ref  -0.27767547  4.631405e-01
## SDHFOODref    0.14232324  7.106595e-01
## SDHMEALSref  -0.28436677  2.070979e-01
## SDHMONEYref   0.23981817  5.372845e-01
## SDHSTRESref  -0.69023785 -2.369587e-01
## GENHLTHref   -0.54438339 -1.789155e-01
## PHYSHLTHref  -0.14030421  2.257779e-01
## MENTHLTHref   0.07438150  4.408748e-01
## POORHLTHref  -0.01926094  4.245692e-01
## SMOKDAY2ref  -0.59951264 -2.194989e-01
## ECIGNOWref   -0.16548175  5.127730e-01
## CVDSTRK3ref  -0.20669410  4.781400e-01
## CVDCRHD4ref  -0.41936846  1.243066e-01
## DIABETE3ref  -0.24162474  1.664921e-01
## ADDEPEV2ref  -0.08842560  2.104847e-01
## HAVARTH3ref  -0.29260755  4.657855e-03
## CHCCOPD1ref  -0.49036415 -1.043690e-02
## DEAFref      -0.21109826  2.251537e-01
## BLINDref     -0.57976984  7.114857e-02
## DECIDEref    -0.52977930 -1.033763e-01
## DIFFWALKref  -0.06419964  3.433735e-01
## DIFFDRESref  -0.62439277 -1.882309e-03
## DIFFALONref  -0.50005792  3.246692e-02
exp(coef(alr))
##  (Intercept)       SEXref   MARITALref     EDUCAref   EMPLOY1ref   INCOME2ref 
##    0.7546094    0.9157292    1.2941618    0.8257352    0.8381668    0.8723182 
## X_BMI5CATref X_AGEG5YRref  CHILDRENref  SDHBILLSref  HOWSAFE1ref   SDHFOODref 
##    1.0825860    0.7549847    1.6227441    0.7522826    1.0971682    1.5318733 
##  SDHMEALSref  SDHMONEYref  SDHSTRESref   GENHLTHref  PHYSHLTHref  MENTHLTHref 
##    0.9621023    1.4748427    0.6290162    0.6965265    1.0436632    1.2938576 
##  POORHLTHref  SMOKDAY2ref   ECIGNOWref  CVDSTRK3ref  CVDCRHD4ref  DIABETE3ref 
##    1.2246488    0.6639783    1.1896339    1.1453645    0.8628358    0.9631306 
##  ADDEPEV2ref  HAVARTH3ref  CHCCOPD1ref      DEAFref     BLINDref    DECIDEref 
##    1.0629303    0.8659095    0.7784889    1.0070525    0.7754509    0.7286383 
##  DIFFWALKref  DIFFDRESref  DIFFALONref 
##    1.1497987    0.7311493    0.7915237
exp(cbind(AOR = coef(alr), confint(alr)))
##                    AOR     2.5 %    97.5 %
## (Intercept)  0.7546094 0.5407825 1.0529838
## SEXref       0.9157292 0.8043635 1.0425136
## MARITALref   1.2941618 1.1340622 1.4768632
## EDUCAref     0.8257352 0.7109951 0.9589921
## EMPLOY1ref   0.8381668 0.7277647 0.9653170
## INCOME2ref   0.8723182 0.7215538 1.0545838
## X_BMI5CATref 1.0825860 0.9355796 1.2526912
## X_AGEG5YRref 0.7549847 0.6165060 0.9245682
## CHILDRENref  1.6227441 1.3931719 1.8901460
## SDHBILLSref  0.7522826 0.5659753 0.9999185
## HOWSAFE1ref  1.0971682 0.7575426 1.5890566
## SDHFOODref   1.5318733 1.1529493 2.0353331
## SDHMEALSref  0.9621023 0.7524906 1.2301030
## SDHMONEYref  1.4748427 1.2710180 1.7113534
## SDHSTRESref  0.6290162 0.5014568 0.7890239
## GENHLTHref   0.6965265 0.5801994 0.8361765
## PHYSHLTHref  1.0436632 0.8690938 1.2532973
## MENTHLTHref  1.2938576 1.0772177 1.5540662
## POORHLTHref  1.2246488 0.9809234 1.5289316
## SMOKDAY2ref  0.6639783 0.5490792 0.8029210
## ECIGNOWref   1.1896339 0.8474853 1.6699155
## CVDSTRK3ref  1.1453645 0.8132684 1.6130713
## CVDCRHD4ref  0.8628358 0.6574619 1.1323630
## DIABETE3ref  0.9631306 0.7853508 1.1811542
## ADDEPEV2ref  1.0629303 0.9153712 1.2342762
## HAVARTH3ref  0.8659095 0.7463150 1.0046687
## CHCCOPD1ref  0.7784889 0.6124033 0.9896174
## DEAFref      1.0070525 0.8096945 1.2525152
## BLINDref     0.7754509 0.5600272 1.0737407
## DECIDEref    0.7286383 0.5887349 0.9017875
## DIFFWALKref  1.1497987 0.9378178 1.4096951
## DIFFDRESref  0.7311493 0.5355866 0.9981195
## DIFFALONref  0.7915237 0.6064955 1.0329997
exp(cbind(AOR = coef(alr), confint(alr)))[-1, ]
##                    AOR     2.5 %    97.5 %
## SEXref       0.9157292 0.8043635 1.0425136
## MARITALref   1.2941618 1.1340622 1.4768632
## EDUCAref     0.8257352 0.7109951 0.9589921
## EMPLOY1ref   0.8381668 0.7277647 0.9653170
## INCOME2ref   0.8723182 0.7215538 1.0545838
## X_BMI5CATref 1.0825860 0.9355796 1.2526912
## X_AGEG5YRref 0.7549847 0.6165060 0.9245682
## CHILDRENref  1.6227441 1.3931719 1.8901460
## SDHBILLSref  0.7522826 0.5659753 0.9999185
## HOWSAFE1ref  1.0971682 0.7575426 1.5890566
## SDHFOODref   1.5318733 1.1529493 2.0353331
## SDHMEALSref  0.9621023 0.7524906 1.2301030
## SDHMONEYref  1.4748427 1.2710180 1.7113534
## SDHSTRESref  0.6290162 0.5014568 0.7890239
## GENHLTHref   0.6965265 0.5801994 0.8361765
## PHYSHLTHref  1.0436632 0.8690938 1.2532973
## MENTHLTHref  1.2938576 1.0772177 1.5540662
## POORHLTHref  1.2246488 0.9809234 1.5289316
## SMOKDAY2ref  0.6639783 0.5490792 0.8029210
## ECIGNOWref   1.1896339 0.8474853 1.6699155
## CVDSTRK3ref  1.1453645 0.8132684 1.6130713
## CVDCRHD4ref  0.8628358 0.6574619 1.1323630
## DIABETE3ref  0.9631306 0.7853508 1.1811542
## ADDEPEV2ref  1.0629303 0.9153712 1.2342762
## HAVARTH3ref  0.8659095 0.7463150 1.0046687
## CHCCOPD1ref  0.7784889 0.6124033 0.9896174
## DEAFref      1.0070525 0.8096945 1.2525152
## BLINDref     0.7754509 0.5600272 1.0737407
## DECIDEref    0.7286383 0.5887349 0.9017875
## DIFFWALKref  1.1497987 0.9378178 1.4096951
## DIFFDRESref  0.7311493 0.5355866 0.9981195
## DIFFALONref  0.7915237 0.6064955 1.0329997
adj_or <- exp(cbind(AOR = coef(alr), confint(alr)))[-1,]
adj_or <- as.data.frame(adj_or)
# Combine All OR with Adjusted OR
stargazer(bind_cols(all_or, adj_or),summary=F,type = "html", digits=2)
OR X2.5.. X97.5.. hv AOR 2.5 % 97.5 %
SEXref 0.85 0.78 0.92 SEX 0.92 0.80 1.04
MARITALref 1.33 1.22 1.45 MARITAL 1.29 1.13 1.48
EDUCAref 0.82 0.74 0.90 EDUCA 0.83 0.71 0.96
EMPLOY1ref 0.85 0.78 0.93 EMPLOY1 0.84 0.73 0.97
INCOME2ref 0.98 0.86 1.11 INCOME2 0.87 0.72 1.05
X_BMI5CATref 1.26 1.14 1.39 X_BMI5CAT 1.08 0.94 1.25
X_AGEG5YRref 0.87 0.75 1.00 X_AGEG5YR 0.75 0.62 0.92
CHILDRENref 1.37 1.25 1.50 CHILDREN 1.62 1.39 1.89
SDHBILLSref 0.57 0.46 0.69 SDHBILLS 0.75 0.57 1.00
HOWSAFE1ref 0.70 0.51 0.95 HOWSAFE1 1.10 0.76 1.59
SDHFOODref 0.82 0.69 0.97 SDHFOOD 1.53 1.15 2.04
SDHMEALSref 0.85 0.73 0.98 SDHMEALS 0.96 0.75 1.23
SDHMONEYref 1.11 1.00 1.22 SDHMONEY 1.47 1.27 1.71
SDHSTRESref 0.44 0.37 0.53 SDHSTRES 0.63 0.50 0.79
GENHLTHref 0.54 0.47 0.61 GENHLTH 0.70 0.58 0.84
PHYSHLTHref 1.68 1.48 1.91 PHYSHLTH 1.04 0.87 1.25
MENTHLTHref 2.00 1.72 2.32 MENTHLTH 1.29 1.08 1.55
POORHLTHref 1.99 1.68 2.35 POORHLTH 1.22 0.98 1.53
SMOKDAY2ref 0.62 0.54 0.70 SMOKDAY2 0.66 0.55 0.80
ECIGNOWref 0.80 0.62 1.03 ECIGNOW 1.19 0.85 1.67
CVDSTRK3ref 0.94 0.75 1.20 CVDSTRK3 1.15 0.81 1.61
CVDCRHD4ref 0.89 0.73 1.07 CVDCRHD4 0.86 0.66 1.13
DIABETE3ref 0.98 0.85 1.12 DIABETE3 0.96 0.79 1.18
ADDEPEV2ref 0.74 0.66 0.82 ADDEPEV2 1.06 0.92 1.23
HAVARTH3ref 0.86 0.79 0.95 HAVARTH3 0.87 0.75 1.00
CHCCOPD1ref 0.60 0.50 0.72 CHCCOPD1 0.78 0.61 0.99
DEAFref 0.93 0.80 1.09 DEAF 1.01 0.81 1.25
BLINDref 0.64 0.50 0.81 BLIND 0.78 0.56 1.07
DECIDEref 0.48 0.42 0.57 DECIDE 0.73 0.59 0.90
DIFFWALKref 0.75 0.66 0.85 DIFFWALK 1.15 0.94 1.41
DIFFDRESref 0.42 0.33 0.53 DIFFDRES 0.73 0.54 1.00
DIFFALONref 0.46 0.38 0.56 DIFFALON 0.79 0.61 1.03
table1 <- bind_cols(all_or, adj_or)

table1 <- table1 %>% 
  dplyr::select("hv", "OR", "X2.5..", "X97.5..", "AOR", "2.5 %", "97.5 %")


table1$orll <- table1$X2.5..
table1$orul <- table1$X97.5..
table1$aorll <- table1$"2.5 %"
table1$aorul <- table1$"97.5 %"
table1 <- table1 %>% dplyr::select(hv, OR, orll, orul, AOR, aorll, aorul)


#Plot OR
ggplot(table1, aes(x=hv, y = OR)) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=orll, ymax=orul), 
                width = .2, position = position_dodge(.9))

#Plot AOR
ggplot(table1, aes(x=hv, y = AOR)) + 
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) +
  theme(axis.text.x = element_text(angle = 90)) +
  geom_errorbar(aes(ymin=aorll, ymax=aorul), 
                width = .2, position = position_dodge(.9))

ORtable <- table1 %>% dplyr::select(hv, OR, orll, orul)
ORtable$type <- c("OR")
ORtable$stat <- ORtable$OR
ORtable$ll <- ORtable$orll
ORtable$ul <- ORtable$orul
ORtable <- ORtable %>% dplyr::select(hv, stat, type, ll, ul)

AORtable <- table1 %>% dplyr::select(hv, AOR, aorll, aorul)
AORtable$type <- c("AOR")
AORtable$stat <- AORtable$AOR
AORtable$ll <- AORtable$aorll
AORtable$ul <- AORtable$aorul
AORtable <- AORtable %>% dplyr::select(hv, stat, type, ll, ul)

table2 <- rbind(ORtable, AORtable)

figureoraor <- ggplot(table2, aes(x=hv, y = stat, fill = type)) +
  geom_bar(stat = "identity", position = "dodge") + 
  geom_abline(slope = 0, intercept = 1, color = "red", size = 2) + 
  theme(axis.text.x = element_text(angle = 90)) + 
  geom_errorbar(aes(ymin=ll, ymax=ul), 
                width = .2, position = position_dodge(.9))

#OR compared to Adjusted OR
print(figureoraor + ggtitle("OR & AOR"))