library(car)
## Loading required package: carData
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(questionr)
library(foreign)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
## 
##     recode
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
brfss2017=read.xport("~/Desktop/DataFolder/brfss.XPT ")
#Marital Status; Are you? (marital status): 1 Married, 2 Divorced, 3 Widowed, 4 Seprarated, 5 Never married, 6 Partner, 9 Refuse
brfss2017$marital<-Recode(brfss2017$MARITAL, recodes="1=1;5=0;else=NA",as.factor=T)
#Sexual Orientation; Do you consider yourself to be? (sexual orientation): 1 Straight, 2 Gay, 3 Bisexual, 4 Other, 7 Don't know, 9 Refuse
brfss2017$sxorient<-Recode(brfss2017$SXORIENT,recodes="1=0;2=1;else=NA",as.factor=T)
#Income 
brfss2017$income<-Recode(brfss2017$INCOME2,recodes="1:3='<$20k';4:5='$20k<$35k';6='35k<50k';7='50k<75';8='>75k';else=NA",as.factor=T)
#Age
brfss2017$age<-Recode(brfss2017$X_AGE_G, recodes="1='18-24';2='25-34';3='35-44';4='45-54';5='55-64';6='65+';else=NA",as.factor=T)
#Education
brfss2017$educ<-Recode(brfss2017$EDUCA, recodes="1:2='0Prim'; 3='1somehs'; 4='2hsgrad'; 5='3somecol'; 6='4colgrad';9=NA", as.factor=T)
brfss2017$educ<-relevel(brfss2017$educ, ref='0Prim')
#Cholesterol; Have you EVER been told by a doctor that your cholesterol is high? 1 Yes, 2 No, 7 Dont know, 9 Refuse
brfss2017$choles<-Recode(brfss2017$TOLDHI2,recodes="1='Y';2='N';else=NA",as.factor=T)
#Blood Pressure; Are you currently taking medicine for blood Pressure? 1 Yes, 2 No, 7 Dont know, 9 Refuse
brfss2017$blpressure<-Recode(brfss2017$BPMEDS,recodes="1='Y';2='N';else=NA",as.factor=T)
#Health Insurance; Do you have health care coverage? 1 Yes, 2 No, 7 Dont know, 9 Refuse
brfss2017$hlthinsur<-Recode(brfss2017$HLTHPLN1,recodes="1='Y';2='N';else=NA",as.factor=T)
#DR Checkup; Had a doctor checkup with the last...?  1 year, 2 years, 5 years, 5+ years
brfss2017$checkup<-Recode(brfss2017$CHECKUP1,recodes="1='1 year';2='2 years';3='5 years';4='5+ years';else=NA",as.factor=T)
#Live in a Safe Neighborhood; 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, 9 Refuse
brfss2017$safeneigh<-Recode(brfss2017$HOWSAFE1,recodes="1:2=0;3:4=1;else=NA",as.factor=T)
#Mental Health; How many days during the past 30 days was your mental health not good? 1-30, 88 None, 77 Don't Know, 99 Refuse
brfss2017$menth<-Recode(brfss2017$MENTHLTH,recodes="88=0;77=NA;99=NA")
#Interaction between marital status and sexual orientation
brfss2017$int<-interaction(brfss2017$marital,brfss2017$sxorient)
brfss2017$int<-as.factor(brfss2017$int)
#Interaction between marital status and sexual orientation recoded to gay people only (gay single and gay married)
brfss2017$int1<-Recode(brfss2017$int,recodes="'M.G'='M.G';'S.G'='S.G';else=NA",as.factor=T)
#Interaction between marital status and sexual orientation recoded to married people only (married straight and married gay)
brfss2017$int2<-Recode(brfss2017$int,recodes="'M.G'='M.G';'M.S'='M.S';else=NA",as.factor=T)
#Homeowner; Do you own or rent your home? 1 Own, 2 Rent, 3 Other, 7 Don't know, 9 Refuse
brfss2017$ownhome<-Recode(brfss2017$RENTHOM1,recodes="1='Y';2:3='N';else=NA",as.factor=T)
#Smoking; Do you now smoke cigarettes every day, some days, or not at all? 1 Everyday, 2 Some days, 3 Not at all, 7 Don't know, 9 Refuse
brfss2017$smoke<-Recode(brfss2017$SMOKDAY2,recodes="1:2='Y';3='N';else=NA",as.factor=T)
#Was there a time in the past 12 months when you needed to see a doctor but could not because of cost? 1 Yes, 2 No, 7 Don't know, 9 Refuse
brfss2017$medcost<-Recode(brfss2017$MEDCOST,recodes="1='Y';2='N';else=NA",as.factor=T)
#During the past 30 days, on the days when you drank, about how many drinks did you drink on the average?
brfss2017$drinks<-Recode(brfss2017$AVEDRNK2,recodes="1:10=0;10:30=1;77=NA;99=NA;else=NA",as.factor=T)
#BMI; Four-categories of Body Mass Index (BMI): 1 Underweight, 2 Normal Weight, 3 Overweight, 4 Obese
brfss2017$bmi<-brfss2017$X_BMI5CAT
#Not good mental health days: 1 (0 days), 2 (1-13 days), 3 (14-30 days), 9 Don't know
brfss2017$badmental<-Recode(brfss2017$X_MENT14D,recodes="1=0;2:3=1;9=NA;else=NA",as.factor=T)
#Race/Ethnicity
brfss2017$black<-Recode(brfss2017$racegr3, recodes="2=1; 9=NA; else=0")
brfss2017$white<-Recode(brfss2017$racegr3, recodes="1=1; 9=NA; else=0")
brfss2017$other<-Recode(brfss2017$racegr3, recodes="3:4=1; 9=NA; else=0")
brfss2017$hispanic<-Recode(brfss2017$racegr3, recodes="5=1; 9=NA; else=0")
#Race/Ethnicity; 1 White, 2 Black, 3 Other, 4 Multiracial, 5 Hispanic, 9 Don't know
brfss2017$race<-Recode(brfss2017$X_RACEGR3, recodes="2='black'; 1='awhite'; 3:4='other';5='hispanic'; else=NA",as.factor=T)
brfss2017$race<-relevel(brfss2017$race, ref='awhite')
#Sex; 1 Male, 2 Female
brfss2017$sex<-Recode(brfss2017$SEX,recodes="1=1;2=0;9=NA;else=NA",as.factor=T)
brfss2017$genh<-Recode(brfss2017$GENHLTH,recodes="1:3=0;4:5=1;else=NA")
#Create a survey design
brfss2017%>%
  filter(complete.cases(.))
##   [1] X_STATE    FMONTH     IDATE      IMONTH     IDAY       IYEAR     
##   [7] DISPCODE   SEQNO      X_PSU      CTELENM1   PVTRESD1   COLGHOUS  
##  [13] STATERE1   CELLFON4   LADULT     NUMADULT   NUMMEN     NUMWOMEN  
##  [19] SAFETIME   CTELNUM1   CELLFON5   CADULT     PVTRESD3   CCLGHOUS  
##  [25] CSTATE1    LANDLINE   HHADULT    GENHLTH    PHYSHLTH   MENTHLTH  
##  [31] POORHLTH   HLTHPLN1   PERSDOC2   MEDCOST    CHECKUP1   BPHIGH4   
##  [37] BPMEDS     CHOLCHK1   TOLDHI2    CHOLMED1   CVDINFR4   CVDCRHD4  
##  [43] CVDSTRK3   ASTHMA3    ASTHNOW    CHCSCNCR   CHCOCNCR   CHCCOPD1  
##  [49] HAVARTH3   ADDEPEV2   CHCKIDNY   DIABETE3   DIABAGE2   LMTJOIN3  
##  [55] ARTHDIS2   ARTHSOCL   JOINPAI1   SEX        MARITAL    EDUCA     
##  [61] RENTHOM1   NUMHHOL2   NUMPHON2   CPDEMO1A   VETERAN3   EMPLOY1   
##  [67] CHILDREN   INCOME2    INTERNET   WEIGHT2    HEIGHT3    PREGNANT  
##  [73] DEAF       BLIND      DECIDE     DIFFWALK   DIFFDRES   DIFFALON  
##  [79] SMOKE100   SMOKDAY2   STOPSMK2   LASTSMK2   USENOW3    ECIGARET  
##  [85] ECIGNOW    ALCDAY5    AVEDRNK2   DRNK3GE5   MAXDRNKS   FRUIT2    
##  [91] FRUITJU2   FVGREEN1   FRENCHF1   POTATOE1   VEGETAB2   EXERANY2  
##  [97] EXRACT11   EXEROFT1   EXERHMM1   EXRACT21   EXEROFT2   EXERHMM2  
## [103] STRENGTH   SEATBELT   FLUSHOT6   FLSHTMY2   PNEUVAC3   SHINGLE2  
## [109] HIVTST6    HIVTSTD3   HIVRISK5   PDIABTST   PREDIAB1   INSULIN   
## [115] BLDSUGAR   FEETCHK2   DOCTDIAB   CHKHEMO3   FEETCHK    EYEEXAM   
## [121] DIABEYE    DIABEDU    COPDCOGH   COPDFLEM   COPDBRTH   COPDBTST  
## [127] COPDSMOK   HAREHAB1   STREHAB1   CVDASPRN   ASPUNSAF   RLIVPAIN  
## [133] RDUCHART   RDUCSTRK   BPEATHBT   BPSALT     BPALCHOL   BPEXER    
## [139] BPEATADV   BPSLTADV   BPALCADV   BPEXRADV   BPMEDADV   BPHI2MR   
## [145] ARTTODAY   ARTHWGT    ARTHEXER   ARTHEDU    ASTHMAGE   ASATTACK  
## [151] ASERVIST   ASDRVIST   ASRCHKUP   ASACTLIM   ASYMPTOM   ASNOSLEP  
## [157] ASTHMED3   ASINHALR   PAINACT2   QLMENTL2   QLSTRES2   QLHLTH2   
## [163] SLEPTIM1   ADSLEEP    SLEPDAY1   SLEPSNO2   SLEPBRTH   MEDICARE  
## [169] HLTHCVR1   DELAYMED   DLYOTHER   NOCOV121   LSTCOVRG   DRVISITS  
## [175] MEDSCOS1   CARERCVD   MEDBILL1   ASBIALCH   ASBIDRNK   ASBIBING  
## [181] ASBIADVC   ASBIRDUC   CNCRDIFF   CNCRAGE    CNCRTYP1   CSRVTRT2  
## [187] CSRVDOC1   CSRVSUM    CSRVRTRN   CSRVINST   CSRVINSR   CSRVDEIN  
## [193] CSRVCLIN   CSRVPAIN   CSRVCTL1   SSBSUGR2   SSBFRUT3   WTCHSALT  
## [199] DRADVISE   MARIJANA   USEMRJN1   RSNMRJNA   PFPPRVN2   TYPCNTR7  
## [205] NOBCUSE6   IMFVPLAC   HPVADVC2   HPVADSHT   TETANUS    LCSFIRST  
## [211] LCSLAST    LCSNUMCG   LCSCTSCN   CAREGIV1   CRGVREL2   CRGVLNG1  
## [217] CRGVHRS1   CRGVPRB2   CRGVPERS   CRGVHOUS   CRGVMST2   CRGVEXPT  
## [223] CIMEMLOS   CDHOUSE    CDASSIST   CDHELP     CDSOCIAL   CDDISCUS  
## [229] EMTSUPRT   LSATISFY   SDHBILLS   SDHMOVE    HOWSAFE1   SDHFOOD   
## [235] SDHMEALS   SDHMONEY   SDHSTRES   SXORIENT   TRNSGNDR   FIREARM4  
## [241] GUNLOAD    LOADULK2   RCSGENDR   RCSRLTN2   CASTHDX2   CASTHNO2  
## [247] QSTVER     QSTLANG    MSCODE     X_STSTR    X_STRWT    X_RAWRAKE 
## [253] X_WT2RAKE  X_IMPRACE  X_CHISPNC  X_CRACE1   X_CPRACE   X_CLLCPWT 
## [259] X_DUALUSE  X_DUALCOR  X_LLCPWT2  X_LLCPWT   X_RFHLTH   X_PHYS14D 
## [265] X_MENT14D  X_HCVU651  X_RFHYPE5  X_CHOLCH1  X_RFCHOL1  X_MICHD   
## [271] X_LTASTH1  X_CASTHM1  X_ASTHMS1  X_DRDXAR1  X_LMTACT1  X_LMTWRK1 
## [277] X_LMTSCL1  X_PRACE1   X_MRACE1   X_HISPANC  X_RACE     X_RACEG21 
## [283] X_RACEGR3  X_RACE_G1  X_AGEG5YR  X_AGE65YR  X_AGE80    X_AGE_G   
## [289] HTIN4      HTM4       WTKG3      X_BMI5     X_BMI5CAT  X_RFBMI5  
## [295] X_CHLDCNT  X_EDUCAG   X_INCOMG   X_SMOKER3  X_RFSMOK3  X_ECIGSTS 
## [301] X_CURECIG  DRNKANY5   DROCDY3_   X_RFBING5  X_DRNKWEK  X_RFDRHV5 
## [307] FTJUDA2_   FRUTDA2_   GRENDA1_   FRNCHDA_   POTADA1_   VEGEDA2_  
## [313] X_MISFRT1  X_MISVEG1  X_FRTRES1  X_VEGRES1  X_FRUTSU1  X_VEGESU1 
## [319] X_FRTLT1A  X_VEGLT1A  X_FRT16A   X_VEG23A   X_FRUITE1  X_VEGETE1 
## [325] X_TOTINDA  METVL11_   METVL21_   MAXVO2_    FC60_      ACTIN11_  
## [331] ACTIN21_   PADUR1_    PADUR2_    PAFREQ1_   PAFREQ2_   X_MINAC11 
## [337] X_MINAC21  STRFREQ_   PAMISS1_   PAMIN11_   PAMIN21_   PA1MIN_   
## [343] PAVIG11_   PAVIG21_   PA1VIGM_   X_PACAT1   X_PAINDX1  X_PA150R2 
## [349] X_PA300R2  X_PA30021  X_PASTRNG  X_PAREC1   X_PASTAE1  X_RFSEAT2 
## [355] X_RFSEAT3  X_FLSHOT6  X_PNEUMO2  X_AIDTST3  marital    sxorient  
## [361] income     age        educ       choles     blpressure hlthinsur 
## [367] checkup    safeneigh  menth      int        int1       int2      
## [373] ownhome    smoke      medcost    drinks     bmi        badmental 
## [379] black      white      other      hispanic   race       sex       
## [385] genh      
## <0 rows> (or 0-length row.names)
options(survey.lonely.psu = "adjust")
des<-svydesign(ids = ~1,strata=~X_STRWT,weights = ~X_LLCPWT,data = brfss2017)
#Mental Health by Marital Status
fit.logit1<-svyglm(badmental~marital,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit1)
## 
## Call:
## svyglm(formula = badmental ~ marital, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.14876    0.01506  -9.877   <2e-16 ***
## marital1    -0.75125    0.01809 -41.528   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.088388)
## 
## Number of Fisher Scoring iterations: 4
#Mental Health by Sexual Orientation
fit.logit2<-svyglm(badmental~sxorient,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit2)
## 
## Call:
## svyglm(formula = badmental ~ sxorient, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.65585    0.01057 -62.020   <2e-16 ***
## sxorient1    0.70461    0.07080   9.952   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.295568)
## 
## Number of Fisher Scoring iterations: 4
table(brfss2017$sxorient)
## 
##      0      1 
## 190310   3167
####MODEL ONE
#Mental Health by Interaction between Mental Health and Sexual Orientation
fit.logit3<-svyglm(badmental~int,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit3)
## 
## Call:
## svyglm(formula = badmental ~ int, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.18154    0.02400  -7.565 3.89e-14 ***
## int1.0      -0.75810    0.02828 -26.808  < 2e-16 ***
## int0.1       0.48298    0.10399   4.644 3.41e-06 ***
## int1.1      -0.39163    0.13634  -2.872  0.00407 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.425193)
## 
## Number of Fisher Scoring iterations: 4
fit.logit4<-svyglm(badmental~int+sex,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit4)
## 
## Call:
## svyglm(formula = badmental ~ int + sex, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.11223    0.02797   4.012 6.02e-05 ***
## int1.0      -0.79768    0.02856 -27.927  < 2e-16 ***
## int0.1       0.55957    0.10754   5.203 1.96e-07 ***
## int1.1      -0.42976    0.13520  -3.179  0.00148 ** 
## sex1        -0.53554    0.02566 -20.870  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.423894)
## 
## Number of Fisher Scoring iterations: 4
regTermTest(fit.logit4, test.terms = ~sex, method="Wald", df = NULL)
## Wald test for sex
##  in svyglm(formula = badmental ~ int + sex, design = des, family = binomial)
## F =  435.543  on  1  and  128057  df: p= < 2.22e-16
fit.logit5<-svyglm(badmental~int+sex+age,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit5)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.28168    0.04275   6.589 4.44e-11 ***
## int1.0      -0.50347    0.03342 -15.063  < 2e-16 ***
## int0.1       0.62346    0.10824   5.760 8.43e-09 ***
## int1.1      -0.18807    0.13982  -1.345   0.1786    
## sex1        -0.53272    0.02592 -20.556  < 2e-16 ***
## age25-34    -0.13649    0.05155  -2.648   0.0081 ** 
## age35-44    -0.23541    0.05497  -4.282 1.85e-05 ***
## age45-54    -0.35428    0.05438  -6.515 7.31e-11 ***
## age55-64    -0.55609    0.05470 -10.166  < 2e-16 ***
## age65+      -0.96722    0.05563 -17.388  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.425918)
## 
## Number of Fisher Scoring iterations: 4
regTermTest(fit.logit5, test.terms = ~sex+age, method="Wald", df = NULL)
## Wald test for sex age
##  in svyglm(formula = badmental ~ int + sex + age, design = des, family = binomial)
## F =  154.2013  on  6  and  128052  df: p= < 2.22e-16
fit.logit6<-svyglm(badmental~int+sex+age+race,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit6)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age + race, design = des, 
##     family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.43657    0.04455   9.800  < 2e-16 ***
## int1.0       -0.54225    0.03466 -15.645  < 2e-16 ***
## int0.1        0.61051    0.11168   5.466 4.60e-08 ***
## int1.1       -0.27427    0.14042  -1.953   0.0508 .  
## sex1         -0.53674    0.02622 -20.472  < 2e-16 ***
## age25-34     -0.12738    0.05202  -2.448   0.0143 *  
## age35-44     -0.23185    0.05562  -4.169 3.06e-05 ***
## age45-54     -0.37647    0.05477  -6.874 6.29e-12 ***
## age55-64     -0.59680    0.05552 -10.749  < 2e-16 ***
## age65+       -1.03365    0.05644 -18.314  < 2e-16 ***
## raceblack    -0.26398    0.04445  -5.938 2.89e-09 ***
## racehispanic -0.32125    0.04270  -7.524 5.35e-14 ***
## raceother    -0.22588    0.05537  -4.080 4.51e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.429427)
## 
## Number of Fisher Scoring iterations: 4
regTermTest(fit.logit6, test.terms = ~sex+age+race, method="Wald", df = NULL)
## Wald test for sex age race
##  in svyglm(formula = badmental ~ int + sex + age + race, design = des, 
##     family = binomial)
## F =  110.9692  on  9  and  126216  df: p= < 2.22e-16
fit.logit7<-svyglm(badmental~int+sex+age+race+educ,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit7)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age + race + educ, design = des, 
##     family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.28224    0.10420   2.709 0.006757 ** 
## int1.0       -0.53328    0.03473 -15.353  < 2e-16 ***
## int0.1        0.62304    0.11141   5.592 2.25e-08 ***
## int1.1       -0.25104    0.14039  -1.788 0.073748 .  
## sex1         -0.54058    0.02624 -20.600  < 2e-16 ***
## age25-34     -0.10885    0.05222  -2.084 0.037134 *  
## age35-44     -0.20843    0.05592  -3.727 0.000194 ***
## age45-54     -0.35408    0.05504  -6.433 1.26e-10 ***
## age55-64     -0.58300    0.05563 -10.480  < 2e-16 ***
## age65+       -1.01691    0.05644 -18.016  < 2e-16 ***
## raceblack    -0.27851    0.04466  -6.236 4.51e-10 ***
## racehispanic -0.33408    0.04569  -7.311 2.66e-13 ***
## raceother    -0.20231    0.05549  -3.646 0.000266 ***
## educ1somehs   0.30997    0.10528   2.944 0.003239 ** 
## educ2hsgrad   0.12606    0.09461   1.332 0.182727    
## educ3somecol  0.18944    0.09454   2.004 0.045099 *  
## educ4colgrad  0.06061    0.09344   0.649 0.516561    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.429457)
## 
## Number of Fisher Scoring iterations: 4
regTermTest(fit.logit7, test.terms = ~sex+age+race+educ, method="Wald", df = NULL)
## Wald test for sex age race educ
##  in svyglm(formula = badmental ~ int + sex + age + race + educ, design = des, 
##     family = binomial)
## F =  78.07223  on  13  and  126001  df: p= < 2.22e-16
####MODEL TWO
fit.logit8<-svyglm(badmental~int+sex+age+race+educ+income,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit8)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age + race + educ + 
##     income, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.48453    0.11661   4.155 3.25e-05 ***
## int1.0          -0.38715    0.03852 -10.050  < 2e-16 ***
## int0.1           0.57751    0.12019   4.805 1.55e-06 ***
## int1.1          -0.16304    0.14571  -1.119 0.263184    
## sex1            -0.52757    0.02805 -18.808  < 2e-16 ***
## age25-34        -0.19024    0.05789  -3.286 0.001017 ** 
## age35-44        -0.30578    0.06108  -5.006 5.55e-07 ***
## age45-54        -0.44642    0.06056  -7.371 1.70e-13 ***
## age55-64        -0.69649    0.06108 -11.402  < 2e-16 ***
## age65+          -1.17440    0.06295 -18.656  < 2e-16 ***
## raceblack       -0.30010    0.04879  -6.151 7.71e-10 ***
## racehispanic    -0.37591    0.04986  -7.540 4.75e-14 ***
## raceother       -0.16216    0.05957  -2.722 0.006488 ** 
## educ1somehs      0.36799    0.11640   3.161 0.001571 ** 
## educ2hsgrad      0.25871    0.10523   2.459 0.013952 *  
## educ3somecol     0.37469    0.10578   3.542 0.000397 ***
## educ4colgrad     0.32319    0.10649   3.035 0.002408 ** 
## income>75k      -0.52706    0.05386  -9.787  < 2e-16 ***
## income$20k<$35k -0.26022    0.05325  -4.887 1.02e-06 ***
## income35k<50k   -0.34742    0.05721  -6.072 1.26e-09 ***
## income50k<75    -0.35922    0.05815  -6.178 6.52e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.423009)
## 
## Number of Fisher Scoring iterations: 4
regTermTest(fit.logit8, test.terms = ~sex+age+race+educ+income, method="Wald", df = NULL)
## Wald test for sex age race educ income
##  in svyglm(formula = badmental ~ int + sex + age + race + educ + 
##     income, design = des, family = binomial)
## F =  61.8658  on  17  and  109397  df: p= < 2.22e-16
####MODEL FIVE
#Mental Health by demographics and "marriage" variables
fit.logit9<-svyglm(genh~int+sex+age+race+educ+income+smoke+drinks+choles+blpressure+bmi+medcost+hlthinsur+checkup+ownhome+safeneigh,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit9)
## 
## Call:
## svyglm(formula = genh ~ int + sex + age + race + educ + income + 
##     smoke + drinks + choles + blpressure + bmi + medcost + hlthinsur + 
##     checkup + ownhome + safeneigh, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -6.54594    1.52878  -4.282 1.92e-05 ***
## int1.0           0.09611    0.24675   0.390 0.696928    
## int0.1           0.39086    0.78373   0.499 0.618020    
## int1.1           0.14695    0.69952   0.210 0.833632    
## sex1             0.22722    0.17645   1.288 0.197949    
## age25-34         3.71460    1.19395   3.111 0.001883 ** 
## age35-44         3.58254    1.19863   2.989 0.002825 ** 
## age45-54         4.21270    1.18367   3.559 0.000379 ***
## age55-64         3.83916    1.18408   3.242 0.001200 ** 
## age65+           3.48992    1.17616   2.967 0.003031 ** 
## raceblack        0.22373    0.30691   0.729 0.466073    
## racehispanic    -0.06138    0.54549  -0.113 0.910414    
## raceother        0.47597    0.38522   1.236 0.216718    
## educ1somehs     -0.16512    0.70630  -0.234 0.815169    
## educ2hsgrad     -0.52406    0.63570  -0.824 0.409794    
## educ3somecol    -0.65440    0.65708  -0.996 0.319376    
## educ4colgrad    -0.79005    0.66258  -1.192 0.233215    
## income>75k      -1.72490    0.35433  -4.868 1.19e-06 ***
## income$20k<$35k -0.27823    0.32234  -0.863 0.388131    
## income35k<50k   -1.00559    0.35075  -2.867 0.004176 ** 
## income50k<75    -1.43253    0.34962  -4.097 4.30e-05 ***
## smokeY           0.39896    0.20754   1.922 0.054666 .  
## drinks1          1.11594    0.54561   2.045 0.040920 *  
## cholesY          0.68532    0.17716   3.868 0.000112 ***
## blpressureY      0.40686    0.29174   1.395 0.163241    
## bmi              0.21274    0.11512   1.848 0.064707 .  
## medcostY         1.05094    0.24326   4.320 1.61e-05 ***
## hlthinsurY       1.01807    0.39478   2.579 0.009965 ** 
## checkup2 years  -0.14232    0.32420  -0.439 0.660704    
## checkup5 years   0.08322    0.53938   0.154 0.877390    
## checkup5+ years  0.78750    0.42535   1.851 0.064218 .  
## ownhomeY         0.40841    0.27407   1.490 0.136297    
## safeneigh1      -0.59306    0.53729  -1.104 0.269781    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.215212)
## 
## Number of Fisher Scoring iterations: 6
regTermTest(fit.logit9, test.terms = ~sex+age+race+educ+income+smoke+drinks+choles+blpressure+bmi+medcost+hlthinsur+checkup+ownhome+safeneigh, method="Wald", df = NULL)
## Wald test for sex age race educ income smoke drinks choles blpressure bmi medcost hlthinsur checkup ownhome safeneigh
##  in svyglm(formula = genh ~ int + sex + age + race + educ + income + 
##     smoke + drinks + choles + blpressure + bmi + medcost + hlthinsur + 
##     checkup + ownhome + safeneigh, design = des, family = binomial)
## F =  5.400662  on  29  and  2743  df: p= < 2.22e-16
####MODEL THREE
fit.logit10<-svyglm(badmental~int+sex+age+race+educ+income+smoke+drinks+choles+blpressure+bmi,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit10)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age + race + educ + 
##     income + smoke + drinks + choles + blpressure + bmi, design = des, 
##     family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.98284    0.67519   1.456 0.145524    
## int1.0          -0.22461    0.14829  -1.515 0.129898    
## int0.1           0.75257    0.38476   1.956 0.050499 .  
## int1.1          -0.29170    0.43598  -0.669 0.503467    
## sex1            -0.63487    0.09424  -6.737 1.72e-11 ***
## age25-34        -0.07978    0.51037  -0.156 0.875783    
## age35-44        -0.70169    0.50898  -1.379 0.168049    
## age45-54        -0.87644    0.50914  -1.721 0.085213 .  
## age55-64        -1.02547    0.50678  -2.023 0.043052 *  
## age65+          -1.70987    0.51221  -3.338 0.000846 ***
## raceblack       -0.06522    0.16020  -0.407 0.683938    
## racehispanic     0.16986    0.21315   0.797 0.425516    
## raceother       -0.18073    0.23222  -0.778 0.436428    
## educ1somehs      0.08364    0.48112   0.174 0.862000    
## educ2hsgrad      0.26355    0.46411   0.568 0.570141    
## educ3somecol     0.45376    0.46529   0.975 0.329470    
## educ4colgrad     0.63438    0.46777   1.356 0.175078    
## income>75k      -1.16181    0.19770  -5.877 4.34e-09 ***
## income$20k<$35k -0.59774    0.20576  -2.905 0.003682 ** 
## income35k<50k   -0.89411    0.20170  -4.433 9.41e-06 ***
## income50k<75    -0.91421    0.20093  -4.550 5.44e-06 ***
## smokeY           0.14551    0.11299   1.288 0.197845    
## drinks1         -0.22664    0.33030  -0.686 0.492633    
## cholesY          0.36974    0.09412   3.928 8.61e-05 ***
## blpressureY     -0.31228    0.11611  -2.690 0.007167 ** 
## bmi              0.09478    0.05903   1.605 0.108426    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.174513)
## 
## Number of Fisher Scoring iterations: 4
####MODEL FOUR
fit.logit11<-svyglm(badmental~int+sex+age+race+educ+income+smoke+drinks+choles+blpressure+bmi+medcost+hlthinsur+checkup,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit11)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age + race + educ + 
##     income + smoke + drinks + choles + blpressure + bmi + medcost + 
##     hlthinsur + checkup, design = des, family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.12833    0.70395   0.182 0.855349    
## int1.0          -0.30473    0.14936  -2.040 0.041356 *  
## int0.1           0.65561    0.38580   1.699 0.089293 .  
## int1.1          -0.35716    0.41814  -0.854 0.393031    
## sex1            -0.61905    0.09636  -6.424 1.39e-10 ***
## age25-34        -0.22879    0.52711  -0.434 0.664265    
## age35-44        -0.89147    0.52499  -1.698 0.089527 .  
## age45-54        -1.04501    0.52308  -1.998 0.045767 *  
## age55-64        -1.14827    0.52190  -2.200 0.027821 *  
## age65+          -1.78846    0.52713  -3.393 0.000695 ***
## raceblack       -0.08733    0.16369  -0.534 0.593671    
## racehispanic     0.19045    0.21601   0.882 0.377991    
## raceother       -0.13518    0.23611  -0.573 0.566977    
## educ1somehs      0.23652    0.46352   0.510 0.609870    
## educ2hsgrad      0.44638    0.44533   1.002 0.316194    
## educ3somecol     0.61900    0.44616   1.387 0.165360    
## educ4colgrad     0.80495    0.44974   1.790 0.073519 .  
## income>75k      -1.06880    0.20346  -5.253 1.53e-07 ***
## income$20k<$35k -0.55837    0.20985  -2.661 0.007808 ** 
## income35k<50k   -0.86685    0.20964  -4.135 3.58e-05 ***
## income50k<75    -0.89454    0.20651  -4.332 1.50e-05 ***
## smokeY           0.13394    0.11579   1.157 0.247412    
## drinks1         -0.13966    0.35522  -0.393 0.694204    
## cholesY          0.35814    0.09623   3.722 0.000199 ***
## blpressureY     -0.25316    0.12259  -2.065 0.038948 *  
## bmi              0.10224    0.06036   1.694 0.090351 .  
## medcostY         0.99378    0.15320   6.487 9.22e-11 ***
## hlthinsurY       0.66238    0.21173   3.128 0.001763 ** 
## checkup2 years  -0.01155    0.15868  -0.073 0.941957    
## checkup5 years   0.37006    0.20844   1.775 0.075868 .  
## checkup5+ years  0.09625    0.23112   0.416 0.677106    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.176246)
## 
## Number of Fisher Scoring iterations: 4
fit.logit9<-svyglm(badmental~int+sex+age+race+educ+income+smoke+drinks+choles+blpressure+bmi+medcost+hlthinsur+checkup+ownhome+safeneigh,design=des,family=binomial)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!
summary(fit.logit9)
## 
## Call:
## svyglm(formula = badmental ~ int + sex + age + race + educ + 
##     income + smoke + drinks + choles + blpressure + bmi + medcost + 
##     hlthinsur + checkup + ownhome + safeneigh, design = des, 
##     family = binomial)
## 
## Survey design:
## svydesign(ids = ~1, strata = ~X_STRWT, weights = ~X_LLCPWT, data = brfss2017)
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.54830    1.25089   0.438 0.661181    
## int1.0          -0.16169    0.24001  -0.674 0.500556    
## int0.1           0.37280    0.58463   0.638 0.523737    
## int1.1           1.13669    0.98863   1.150 0.250345    
## sex1            -0.45078    0.15885  -2.838 0.004576 ** 
## age25-34        -0.57685    0.94754  -0.609 0.542716    
## age35-44        -1.12223    0.96125  -1.167 0.243122    
## age45-54        -0.79643    0.94962  -0.839 0.401719    
## age55-64        -1.11845    0.95800  -1.167 0.243121    
## age65+          -1.74400    0.95456  -1.827 0.067807 .  
## raceblack       -0.11213    0.31341  -0.358 0.720531    
## racehispanic     0.14686    0.47654   0.308 0.757972    
## raceother       -0.06902    0.42516  -0.162 0.871045    
## educ1somehs     -0.04017    0.79056  -0.051 0.959474    
## educ2hsgrad      0.19865    0.74582   0.266 0.789989    
## educ3somecol     0.23813    0.76295   0.312 0.754971    
## educ4colgrad     0.41696    0.76405   0.546 0.585305    
## income>75k      -0.72867    0.35497  -2.053 0.040190 *  
## income$20k<$35k -0.62400    0.35315  -1.767 0.077347 .  
## income35k<50k   -0.50571    0.36094  -1.401 0.161301    
## income50k<75    -0.79036    0.36071  -2.191 0.028528 *  
## smokeY           0.10633    0.18426   0.577 0.563952    
## drinks1         -0.96876    0.54821  -1.767 0.077322 .  
## cholesY          0.60338    0.15683   3.847 0.000122 ***
## blpressureY     -0.15075    0.22526  -0.669 0.503415    
## bmi              0.04895    0.10158   0.482 0.629935    
## medcostY         0.59763    0.24935   2.397 0.016608 *  
## hlthinsurY       0.62896    0.36508   1.723 0.085036 .  
## checkup2 years  -0.10696    0.27540  -0.388 0.697756    
## checkup5 years   0.32157    0.37913   0.848 0.396415    
## checkup5+ years  0.81412    0.45872   1.775 0.076050 .  
## ownhomeY        -0.49428    0.24551  -2.013 0.044184 *  
## safeneigh1       0.93952    0.42573   2.207 0.027409 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1.187565)
## 
## Number of Fisher Scoring iterations: 4
stargazer(fit.logit3, fit.logit8, fit.logit10,fit.logit11,fit.logit9,type = "html", style="demography", covariate.labels =c("SM","GS" ,"GM","Male", "25-34", "35-44","45-54", "55-64",  "65+", "Back", "Hisp","Other","someHS","HSgrad","someCol","Colgrad","75+","20-35","35-50","50-75","smokeY","drinks1","cholesY","blpressY","bmi","medcostY","hlthinsY","CU2","CU5","CU5+","ownhome","safeneigh"), ci = T )
badmental
Model 1 Model 2 Model 3 Model 4 Model 5
SM -0.758*** -0.387*** -0.225 -0.305* -0.162
(-0.814, -0.703) (-0.463, -0.312) (-0.515, 0.066) (-0.597, -0.012) (-0.632, 0.309)
GS 0.483*** 0.578*** 0.753 0.656 0.373
(0.279, 0.687) (0.342, 0.813) (-0.002, 1.507) (-0.101, 1.412) (-0.773, 1.519)
GM -0.392** -0.163 -0.292 -0.357 1.137
(-0.659, -0.124) (-0.449, 0.123) (-1.146, 0.563) (-1.177, 0.462) (-0.801, 3.074)
Male -0.528*** -0.635*** -0.619*** -0.451**
(-0.583, -0.473) (-0.820, -0.450) (-0.808, -0.430) (-0.762, -0.139)
25-34 -0.190** -0.080 -0.229 -0.577
(-0.304, -0.077) (-1.080, 0.921) (-1.262, 0.804) (-2.434, 1.280)
35-44 -0.306*** -0.702 -0.891 -1.122
(-0.425, -0.186) (-1.699, 0.296) (-1.920, 0.137) (-3.006, 0.762)
45-54 -0.446*** -0.876 -1.045* -0.796
(-0.565, -0.328) (-1.874, 0.121) (-2.070, -0.020) (-2.658, 1.065)
55-64 -0.696*** -1.025* -1.148* -1.118
(-0.816, -0.577) (-2.019, -0.032) (-2.171, -0.125) (-2.996, 0.759)
65+ -1.174*** -1.710*** -1.788*** -1.744
(-1.298, -1.051) (-2.714, -0.706) (-2.822, -0.755) (-3.615, 0.127)
Back -0.300*** -0.065 -0.087 -0.112
(-0.396, -0.204) (-0.379, 0.249) (-0.408, 0.233) (-0.726, 0.502)
Hisp -0.376*** 0.170 0.190 0.147
(-0.474, -0.278) (-0.248, 0.588) (-0.233, 0.614) (-0.787, 1.081)
Other -0.162** -0.181 -0.135 -0.069
(-0.279, -0.045) (-0.636, 0.274) (-0.598, 0.328) (-0.902, 0.764)
someHS 0.368** 0.084 0.237 -0.040
(0.140, 0.596) (-0.859, 1.027) (-0.672, 1.145) (-1.590, 1.509)
HSgrad 0.259* 0.264 0.446 0.199
(0.052, 0.465) (-0.646, 1.173) (-0.426, 1.319) (-1.263, 1.660)
someCol 0.375*** 0.454 0.619 0.238
(0.167, 0.582) (-0.458, 1.366) (-0.255, 1.493) (-1.257, 1.733)
Colgrad 0.323** 0.634 0.805 0.417
(0.114, 0.532) (-0.282, 1.551) (-0.077, 1.686) (-1.081, 1.914)
75+ -0.527*** -1.162*** -1.069*** -0.729*
(-0.633, -0.422) (-1.549, -0.774) (-1.468, -0.670) (-1.424, -0.033)
20-35 -0.260*** -0.598** -0.558** -0.624
(-0.365, -0.156) (-1.001, -0.194) (-0.970, -0.147) (-1.316, 0.068)
35-50 -0.347*** -0.894*** -0.867*** -0.506
(-0.460, -0.235) (-1.289, -0.499) (-1.278, -0.456) (-1.213, 0.202)
50-75 -0.359*** -0.914*** -0.895*** -0.790*
(-0.473, -0.245) (-1.308, -0.520) (-1.299, -0.490) (-1.497, -0.083)
smokeY 0.146 0.134 0.106
(-0.076, 0.367) (-0.093, 0.361) (-0.255, 0.467)
drinks1 -0.227 -0.140 -0.969
(-0.874, 0.421) (-0.836, 0.557) (-2.043, 0.106)
cholesY 0.370*** 0.358*** 0.603***
(0.185, 0.554) (0.170, 0.547) (0.296, 0.911)
blpressY -0.312** -0.253* -0.151
(-0.540, -0.085) (-0.493, -0.013) (-0.592, 0.291)
bmi 0.095 0.102 0.049
(-0.021, 0.210) (-0.016, 0.221) (-0.150, 0.248)
medcostY 0.994*** 0.598*
(0.694, 1.294) (0.109, 1.086)
hlthinsY 0.662** 0.629
(0.247, 1.077) (-0.087, 1.344)
CU2 -0.012 -0.107
(-0.323, 0.299) (-0.647, 0.433)
CU5 0.370 0.322
(-0.038, 0.779) (-0.422, 1.065)
CU5+ 0.096 0.814
(-0.357, 0.549) (-0.085, 1.713)
ownhome -0.494*
(-0.975, -0.013)
safeneigh 0.940*
(0.105, 1.774)
Constant -0.182*** 0.485*** 0.983 0.128 0.548
(-0.229, -0.135) (0.256, 0.713) (-0.341, 2.306) (-1.251, 1.508) (-1.903, 3.000)
N 129,075 110,388 9,878 9,793 3,059
Log Likelihood -110,251.300 -91,350.100 -5,993.179 -5,823.441 -1,944.332
AIC 220,510.600 182,742.200 12,038.360 11,708.880 3,954.664
p < .05; p < .01; p < .001
car::vif(fit.logit9)
##                GVIF Df GVIF^(1/(2*Df))
## int        1.767976  3        1.099629
## sex        1.134080  1        1.064932
## age        2.699401  5        1.104401
## race       1.829708  3        1.105937
## educ       2.669204  4        1.130571
## income     3.076330  4        1.150811
## smoke      1.470649  1        1.212703
## drinks     1.069380  1        1.034108
## choles     1.196838  1        1.094001
## blpressure 1.739478  1        1.318893
## bmi        1.248594  1        1.117405
## medcost    1.299942  1        1.140150
## hlthinsur  1.392280  1        1.179949
## checkup    1.838199  3        1.106790
## ownhome    1.740114  1        1.319134
## safeneigh  1.106986  1        1.052134