Using BRFSS 2017, were there associations and interactions between variables with the outcome of falling asleep unintentially during the day at least once in the past 2 weeks (‘untentslep’). Is there statistical evidence to support stratification of a variable in subsequent analysis (test regression terms using Wald). Only data for respondents in the labor force will be used.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(survey)
## Loading required package: grid
## Loading required package: Matrix
## Loading required package: survival
##
## Attaching package: 'survey'
## The following object is masked from 'package:graphics':
##
## dotchart
library(haven)
mydata<-haven::read_xpt("~/Documents/1A_DEM Doctorate/DEM 7283/R/LLCP2017.xpt")
#names(mydata)
newnames<-tolower(gsub(pattern = "_", replacement = "", x= names(mydata)))
names(mydata)<-newnames
###Binary outocme variable will be 'unintentslep' yes or no which is a recoded 'slepday1'. The variable 'slepday1' which is the number of self-reported days the respondent unintentionally fell asleep during the day.
#recode the number of hours of sleep to binary
mydata$unintentslep<-Recode(mydata$slepday1, recodes ="1:14=1; 88=0; else=NA")
#recode sex variable to male or female
mydata$male<-Recode(mydata$sex, recodes="1='male'; 2='0female'; else=NA")
#recode 5 level race/ethnicity
mydata <- mydata %>%
mutate(racethlvl = ifelse(racegr3 == 1, "0nh white",
ifelse(racegr3== 2, "nh black",
ifelse(racegr3 == 3, "nh other/multi",
ifelse(racegr3 == 4, "nh other/multi",
ifelse(racegr3 == 5, "hispanic", NA))))))
#individual dummy variables
mydata$black<-Recode(mydata$racegr3, recodes="2='nh black';9=NA; else='0non black'")
mydata$white<-Recode(mydata$racegr3, recodes="1='nh white'; 9=NA; else='0non white'")
mydata$other<-Recode(mydata$racegr3, recodes="3:4='nh other/multi'; 9=NA; else='0non other/multi'")
mydata$hispanic<-Recode(mydata$racegr3, recodes="5='hispanic'; 9=NA; else='0non hispanic'")
#recode marital status
mydata <- mydata %>%
mutate(marital = ifelse(marital == 1, "Married",
ifelse(marital == 2, "PrevMarried",
ifelse(marital == 3, "PrevMarried",
ifelse(marital == 4, "PrevMarried",
ifelse(marital == 5, "0NevMarried", NA))))))
#dummy variable married
mydata$married<-Recode(mydata$marital, recodes="1='married'; 2:5='0no'; else=NA")
#recode education
mydata <- mydata %>%
mutate(educlvl = ifelse(educag == 1, "lessHS",
ifelse(educag == 2, "HS",
ifelse(educag == 3, "Some Col",
ifelse(educag == 4, "Col Grad", NA)))))
#dummy variable education
mydata$col <- Recode(mydata$educag, recodes="1:2='0LessCol'; 3:4='Col'; else=NA")
#difficulty concentrating or remembering
mydata$brainf<-Recode(mydata$decide, recodes ="1='brainf'; 2='0no'; else=NA")
#recode poor health (either mental or physcial)
mydata$poorhlthnew<-Recode(mydata$poorhlth, recodes ="1:30='poor'; 88='0good'; else=NA")
#recode last checkup
mydata <- mydata %>%
mutate(recchecklvl = ifelse(checkup1 == 1, "<1 yr",
ifelse(checkup1 == 2, "<2 yr",
ifelse(checkup1 == 3, "<5 yr",
ifelse(checkup1 == 4, "5+", NA)))))
#dummy variable recent checkup (within 1 year)
mydata$reccheck<-Recode(mydata$checkup1, recodes ="1='recent'; 2:4='0no'; else=NA")
#recode laborforce etc
mydata$laborforce<-Recode(mydata$employ1, recodes="1:4='labforce'; 5:8='0no'; else=NA")
#recode employment
mydata$employyes<-Recode(mydata$employ1, recodes="1:2='employed'; 3:4='0no'; else=NA")
#recode select illness
#mydata$hrdx <- Recode(mydata$crgvprb2, recode="8=1; 1:7=0; 9:76=0; else=NA")
#mydata$subst <- Recode(mydata$crgvprb2, recode="12=1; 1:11=0; 13:76=0; else=NA")
#mydata$injur <- Recode(mydata$crgvprb2, recode="13=1; 1:12=0; 14:76=0; else=NA")
#mydata$mentanx <- Recode(mydata$crgvprb2, recode="10=1; 1:9=0; 11:76=0; else=NA")
mydatalf<-mydata %>%
select(unintentslep, male, racethlvl, black, white, other, hispanic, marital, married, educlvl, col, brainf, poorhlthnew, recchecklvl, reccheck, laborforce, employyes, llcpwt) %>%
filter(laborforce=='labforce') %>%
filter(is.na(llcpwt)==F)
#complete.cases(.)
#str(mydatalf)
options(survey.lonely.psu = "adjust")
desmydata<-svydesign(ids=~1, weights=~llcpwt, data=mydatalf)
fit.logitint1 <- svyglm(unintentslep ~ male + hispanic + col + marital + employyes + brainf + poorhlthnew*reccheck, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint1, test.terms = ~poorhlthnew:reccheck, method ="Wald", df=NULL)
## Wald test for poorhlthnew:reccheck
## in svyglm(formula = unintentslep ~ male + hispanic + col + marital +
## employyes + brainf + poorhlthnew * reccheck, design = desmydata,
## family = binomial)
## F = 0.02629401 on 1 and 12175 df: p= 0.87119
No statistical justification to proceed with stratification as the interation of the regression terms (poor health and recent check up) is not statistically significant (p=0.87119). If there is conceptual justification then stratification may be prudent; however, in this case we will not proceed wih stratisfication.
fit.logitint2 <- svyglm(unintentslep ~ male + hispanic + col + marital*employyes + brainf + poorhlthnew + reccheck, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint2, test.terms = ~marital:employyes, method ="Wald", df=NULL)
## Wald test for marital:employyes
## in svyglm(formula = unintentslep ~ male + hispanic + col + marital *
## employyes + brainf + poorhlthnew + reccheck, design = desmydata,
## family = binomial)
## F = 0.1343431 on 2 and 12174 df: p= 0.87429
No statistical justification to proceed with stratification as the interation of the regression terms (marital status and employment status) is not statistically significant (p=0.87429). If there is conceptual justification then stratification may be prudent; however, in this case we will not proceed wih stratisfication.
fit.logitint3 <- svyglm(unintentslep ~ male*hispanic + col + marital + employyes + brainf + poorhlthnew + reccheck, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint3, test.terms = ~male:hispanic, method ="Wald", df=NULL)
## Wald test for male:hispanic
## in svyglm(formula = unintentslep ~ male * hispanic + col + marital +
## employyes + brainf + poorhlthnew + reccheck, design = desmydata,
## family = binomial)
## F = 2.368534 on 1 and 12175 df: p= 0.12383
No statistical justification to proceed with stratification as the interation of the regression terms (sex and hispanic ethnicity) is not statistically significant (p=0.12383). If there is conceptual justification then stratification may be prudent; however, in this case we will not proceed wih stratisfication.
fit.logitint4 <- svyglm(unintentslep ~ male + hispanic*col + marital + employyes + brainf + poorhlthnew + reccheck, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint4, test.terms = ~hispanic:col, method ="Wald", df=NULL)
## Wald test for hispanic:col
## in svyglm(formula = unintentslep ~ male + hispanic * col + marital +
## employyes + brainf + poorhlthnew + reccheck, design = desmydata,
## family = binomial)
## F = 1.074669 on 1 and 12175 df: p= 0.29991
No statistical justification to proceed with stratification as the interation of the regression terms (hispanic ethnicity and college education) is not statistically significant (p=0.29991). If there is conceptual justification then stratification may be prudent; however, in this case we will not proceed wih stratisfication.
fit.logitint5 <- svyglm(unintentslep ~ male + racethlvl*marital + col + employyes + brainf + poorhlthnew + reccheck, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint5, test.terms = ~racethlvl:marital, method ="Wald", df=NULL)
## Wald test for racethlvl:marital
## in svyglm(formula = unintentslep ~ male + racethlvl * marital +
## col + employyes + brainf + poorhlthnew + reccheck, design = desmydata,
## family = binomial)
## F = 2.073971 on 6 and 12168 df: p= 0.052852
No statistical justification to proceed with stratification as the interation of the regression terms (race/ethnicity and marital status) is not statistically significant (p=0.052852). If there is conceptual justification then stratification may be prudent; however, in this case we will not proceed wih stratisfication.
fit.logitint6 <- svyglm(unintentslep ~ male + racethlvl + educlvl*marital + employyes + brainf + poorhlthnew + recchecklvl, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint6, test.terms = ~educlvl:marital, method ="Wald", df=NULL)
## Wald test for educlvl:marital
## in svyglm(formula = unintentslep ~ male + racethlvl + educlvl *
## marital + employyes + brainf + poorhlthnew + recchecklvl,
## design = desmydata, family = binomial)
## F = 0.4777663 on 6 and 12164 df: p= 0.82538
No statistical justification to proceed with stratification as the interation of the regression terms (educational attainment and marital status) is not statistically significant (p=0.82538). If there is conceptual justification then stratification may be prudent; however, in this case we will not proceed wih stratisfication.
fit.logitint7 <- svyglm(unintentslep ~ male + racethlvl*marital + educlvl + employyes + brainf + poorhlthnew + recchecklvl, design = desmydata, family = binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
regTermTest(fit.logitint7, test.terms = ~racethlvl:marital, method ="Wald", df=NULL)
## Wald test for racethlvl:marital
## in svyglm(formula = unintentslep ~ male + racethlvl * marital +
## educlvl + employyes + brainf + poorhlthnew + recchecklvl,
## design = desmydata, family = binomial)
## F = 2.11936 on 6 and 12164 df: p= 0.047851
There is statistical justification to proceed with stratification as the interaction of the regression terms (race/ethnicity and marital status) is statistically significant per the Wald test (p<0.05).
fit.unrestricted <- svyglm(unintentslep~male+marital+educlvl+employyes+brainf+poorhlthnew+recchecklvl, design=desmydata, family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
fit.logit.white <- svyglm(unintentslep~(male+marital+educlvl+employyes+brainf+poorhlthnew+recchecklvl), design=subset(desmydata, white=='nh white'), family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
fit.logit.black <- svyglm(unintentslep~(male+marital+educlvl+employyes+brainf+poorhlthnew+recchecklvl), design=subset(desmydata, black=='nh black'), family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
fit.logit.other <- svyglm(unintentslep~(male+marital+educlvl+employyes+brainf+poorhlthnew+recchecklvl), design=subset(desmydata, other=='nh other/multi'), family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
fit.logit.hispanic <- svyglm(unintentslep~(male+marital+educlvl+employyes+brainf+poorhlthnew+recchecklvl), design=subset(desmydata, hispanic=='hispanic'), family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
stargazer (fit.logit.white, fit.logit.black, fit.logit.other, fit.logit.hispanic, style="demography", type="html", title ="Logit regression models for unintentional falling asleep using survey data - BRFSS", column.labels = c("NH White", "NH Black", "NH Other/Multi", "Hispanic"), covariate.labels =c("Male", "Married", "Previously Married", "High School", "Less than High School", "Some College", "Employed", "Concentration Probs", "Poor Health", "Recent checkup <2yr", "Recent checkup <5yr", "Recent checkup 5+yr"), keep.stat="n", model.names=F, align=T, ci=T)
##
## <table style="text-align:center"><caption><strong>Logit regression models for unintentional falling asleep using survey data - BRFSS</strong></caption>
## <tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"></td><td colspan="4">unintentslep</td></tr>
## <tr><td style="text-align:left"></td><td>NH White</td><td>NH Black</td><td>NH Other/Multi</td><td>Hispanic</td></tr>
## <tr><td style="text-align:left"></td><td>Model 1</td><td>Model 2</td><td>Model 3</td><td>Model 4</td></tr>
## <tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">Male</td><td>0.109</td><td>-0.043</td><td>0.260</td><td>0.422<sup>*</sup></td></tr>
## <tr><td style="text-align:left"></td><td>(-0.045, 0.263)</td><td>(-0.602, 0.516)</td><td>(-0.225, 0.746)</td><td>(0.043, 0.801)</td></tr>
## <tr><td style="text-align:left">Married</td><td>-0.063</td><td>-0.544</td><td>-0.630<sup>*</sup></td><td>-0.647<sup>**</sup></td></tr>
## <tr><td style="text-align:left"></td><td>(-0.254, 0.129)</td><td>(-1.127, 0.040)</td><td>(-1.178, -0.083)</td><td>(-1.073, -0.220)</td></tr>
## <tr><td style="text-align:left">Previously Married</td><td>0.122</td><td>-0.615</td><td>-0.509</td><td>-0.259</td></tr>
## <tr><td style="text-align:left"></td><td>(-0.102, 0.346)</td><td>(-1.279, 0.049)</td><td>(-1.134, 0.116)</td><td>(-0.785, 0.267)</td></tr>
## <tr><td style="text-align:left">High School</td><td>0.380<sup>***</sup></td><td>0.582</td><td>0.149</td><td>0.520</td></tr>
## <tr><td style="text-align:left"></td><td>(0.180, 0.580)</td><td>(-0.134, 1.297)</td><td>(-0.432, 0.731)</td><td>(-0.008, 1.048)</td></tr>
## <tr><td style="text-align:left">Less than High School</td><td>0.653<sup>**</sup></td><td>0.399</td><td>-0.127</td><td>0.059</td></tr>
## <tr><td style="text-align:left"></td><td>(0.264, 1.042)</td><td>(-0.861, 1.658)</td><td>(-1.503, 1.248)</td><td>(-0.551, 0.668)</td></tr>
## <tr><td style="text-align:left">Some College</td><td>0.278<sup>**</sup></td><td>0.328</td><td>0.101</td><td>0.386</td></tr>
## <tr><td style="text-align:left"></td><td>(0.112, 0.443)</td><td>(-0.282, 0.938)</td><td>(-0.492, 0.695)</td><td>(-0.133, 0.905)</td></tr>
## <tr><td style="text-align:left">Employed</td><td>-0.463<sup>***</sup></td><td>-0.561</td><td>-0.292</td><td>-0.921<sup>**</sup></td></tr>
## <tr><td style="text-align:left"></td><td>(-0.700, -0.225)</td><td>(-1.303, 0.180)</td><td>(-0.946, 0.362)</td><td>(-1.477, -0.365)</td></tr>
## <tr><td style="text-align:left">Concentration Probs</td><td>0.541<sup>***</sup></td><td>0.907<sup>*</sup></td><td>0.876<sup>**</sup></td><td>-0.113</td></tr>
## <tr><td style="text-align:left"></td><td>(0.313, 0.769)</td><td>(0.143, 1.671)</td><td>(0.255, 1.498)</td><td>(-0.614, 0.388)</td></tr>
## <tr><td style="text-align:left">Poor Health</td><td>0.443<sup>***</sup></td><td>0.437</td><td>0.408</td><td>0.308</td></tr>
## <tr><td style="text-align:left"></td><td>(0.286, 0.600)</td><td>(-0.121, 0.994)</td><td>(-0.084, 0.899)</td><td>(-0.078, 0.694)</td></tr>
## <tr><td style="text-align:left">Recent checkup <2yr</td><td>0.025</td><td>-0.612</td><td>0.589</td><td>-0.147</td></tr>
## <tr><td style="text-align:left"></td><td>(-0.202, 0.253)</td><td>(-1.395, 0.172)</td><td>(-0.063, 1.241)</td><td>(-0.683, 0.390)</td></tr>
## <tr><td style="text-align:left">Recent checkup <5yr</td><td>-0.047</td><td>-1.141<sup>*</sup></td><td>-0.183</td><td>-0.201</td></tr>
## <tr><td style="text-align:left"></td><td>(-0.302, 0.209)</td><td>(-2.224, -0.058)</td><td>(-0.968, 0.603)</td><td>(-0.745, 0.343)</td></tr>
## <tr><td style="text-align:left">Recent checkup 5+yr</td><td>0.076</td><td>-0.401</td><td>-0.403</td><td>-0.262</td></tr>
## <tr><td style="text-align:left"></td><td>(-0.184, 0.337)</td><td>(-1.519, 0.717)</td><td>(-1.183, 0.376)</td><td>(-0.825, 0.301)</td></tr>
## <tr><td style="text-align:left">Constant</td><td>-1.481<sup>***</sup></td><td>-0.373</td><td>-0.882</td><td>-0.338</td></tr>
## <tr><td style="text-align:left"></td><td>(-1.801, -1.160)</td><td>(-1.349, 0.602)</td><td>(-1.764, 0.0004)</td><td>(-1.093, 0.418)</td></tr>
## <tr><td style="text-align:left"><em>N</em></td><td>9,559</td><td>902</td><td>803</td><td>922</td></tr>
## <tr><td colspan="5" style="border-bottom: 1px solid black"></td></tr><tr><td colspan="5" style="text-align:left"><sup>*</sup>p < .05; <sup>**</sup>p < .01; <sup>***</sup>p < .001</td></tr>
## </table>
There was a positive association between male and likelihood of unintentionally falling asleep during the day only with respondents of hispanic ethnicity. There was a negative association between being married compared to not ever being married and the outcome variable in NH Other/Multi and Hispanic populations in the labor force. No associtions with previously married compared to married in either race/ethnic category. Only “NH White” respondents with less than high school, high school, and some college education compared to college education were more likely to unintentially fall asleep during the day. Respondents that were employed were less likely to report unintentially falling asleep if they were NH White or Hispanic with Hispanics having the estimate with the greater magnitde. All the Non Hispanic groups had negative associations between reporting concentration problems and likelihood of unintentionally falling asleep during the day, while Hispanic group did not. Having poor health was associated with unintentionally falling asleep in the NH White group only. Lastly, only the NH Black group was more likely to report unintentionally falling asleep during the day if they had a recent check up within 5 years of survey compared to within the past year.