library(car)
## Loading required package: carData
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. 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(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
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ stringr 1.4.1
## ✔ tidyr   1.2.0     ✔ forcats 0.5.2
## ✔ readr   2.1.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::expand() masks Matrix::expand()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ✖ tidyr::pack()   masks Matrix::pack()
## ✖ dplyr::recode() masks car::recode()
## ✖ purrr::some()   masks car::some()
## ✖ tidyr::unpack() masks Matrix::unpack()
library(broom)
library(emmeans)
library(table1)
## 
## Attaching package: 'table1'
## 
## The following objects are masked from 'package:base':
## 
##     units, units<-
library(ggplot2)
library(haven)
library(psych)
## 
## Attaching package: 'psych'
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## 
## The following object is masked from 'package:questionr':
## 
##     describe
## 
## The following object is masked from 'package:car':
## 
##     logit
library(gmodels)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(ResourceSelection)
## ResourceSelection 0.3-6   2023-06-27
x38304_0001_Data <- read_sav("WorkingDirectoryFall2020StatsDem1/38304-0001-Data.sav")
View(x38304_0001_Data)
x38304_0001_Data$sui_th<-Recode(x38304_0001_Data$SBQ_1, recodes= "1=0; 2:4=1; else=NA", as.numeric=T)
summary(x38304_0001_Data$sui_th)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##  0.0000  0.0000  0.0000  0.3884  1.0000  1.0000      84
x38304_0001_Data$ho_suith<-Recode(x38304_0001_Data$SBQ_2, recodes="1=1; 2:3=2; 4:5=3; else=NA", as.factor = T)
x38304_0001_Data$ho_suith<-relevel(x38304_0001_Data$ho_suith, ref ="1")
summary(x38304_0001_Data$ho_suith)
##    1    2    3 NA's 
## 1086  311   87   11
x38304_0001_Data$sex<-Recode(x38304_0001_Data$GENDER, recodes="1=1; 2=0; else=NA", as.factor = T)
summary(x38304_0001_Data$sex)
##    0    1 NA's 
##  483 1004    8
x38304_0001_Data$ce<-Recode(x38304_0001_Data$CES_1, recodes="1=1; 2=2; 3=3; 4=4; 5=5; else=NA", as.factor=T)
summary(x38304_0001_Data$ce)
##   1   2   3   4   5 
## 752 298 210 134 101
x38304_0001_Data$RACE <-as.numeric(x38304_0001_Data$RACE)
x38304_0001_Data$race2<-Recode(x38304_0001_Data$RACE, recodes="1='white'; 2='black'; 3:6='other'; 
                               else=NA", as.factor=T)
x38304_0001_Data$race2<-relevel(x38304_0001_Data$race2, ref='white')
summary(x38304_0001_Data$race2)
## white black other 
##  1129   215   151
x38304_0001_Data$SOC_INTEGRATION_1 <-as.numeric(x38304_0001_Data$SOC_INTEGRATION_1)
x38304_0001_Data$bel_com<-Recode(x38304_0001_Data$SOC_INTEGRATION_1, recodes="1:3='disagree'; 4='neutral'; 5:7='agree'; else=NA", as.factor =T)
x38304_0001_Data$ bel_com <-relevel(x38304_0001_Data$ bel_com, ref='agree')
summary(x38304_0001_Data$bel_com)
##    agree disagree  neutral 
##      411      807      277
x38304_0001_Data$SOC_INTEGRATION_2 <-as.numeric(x38304_0001_Data$SOC_INTEGRATION_2)
x38304_0001_Data$clo_peo<-Recode(x38304_0001_Data$SOC_INTEGRATION_2, recodes="1:3='disagree'; 4='neutral'; 5:7='agree'; else=NA", as.factor =T)
x38304_0001_Data$clo_peo <-relevel(x38304_0001_Data$clo_peo, ref='agree')
summary(x38304_0001_Data$clo_peo)
##    agree disagree  neutral 
##      758      426      311
x38304_0001_Data$SOC_INTEGRATION_3 <-as.numeric(x38304_0001_Data$SOC_INTEGRATION_3)
x38304_0001_Data$com_comf<-Recode(x38304_0001_Data$SOC_INTEGRATION_3, recodes="1:3='disagree'; 4='neutral'; 5:7='agree'; else=NA", as.factor =T)
x38304_0001_Data$com_comf <-relevel(x38304_0001_Data$com_comf, ref='agree')
summary(x38304_0001_Data$com_comf)
##    agree disagree  neutral 
##      736      385      374
x38304_0001_Data$WELLNESS_8 <-as.numeric(x38304_0001_Data$WELLNESS_8)
x38304_0001_Data$fam_help<-Recode(x38304_0001_Data$WELLNESS_8, recodes="1:3='disagree'; 4='neutral'; 5:7='agree'; else=NA", as.factor =T)
x38304_0001_Data$fam_help <-relevel(x38304_0001_Data$fam_help, ref='agree')
summary(x38304_0001_Data$fam_help)
##    agree disagree  neutral 
##      131     1053      311
x38304_0001_Data$WELLNESS_28 <-as.numeric(x38304_0001_Data$WELLNESS_28)
x38304_0001_Data$fri_help<-Recode(x38304_0001_Data$WELLNESS_28, recodes="1:3='disagree'; 4='neutral'; 5:7='agree'; else=NA", as.factor =T)
x38304_0001_Data$ fri_help <-relevel(x38304_0001_Data$fri_help, ref='agree')
summary(x38304_0001_Data$fri_help)
##    agree disagree  neutral 
##      317      610      568
x38304_0001_Data$rel_stat<-Recode(x38304_0001_Data$MARITAL, recodes="1=1; 2=0; 3=0; 4=1; 5=1; else=NA", as.factor=T)
summary(x38304_0001_Data$rel_stat)
##   0   1 
## 959 536
sub2<-x38304_0001_Data%>%
  select(sui_th, sex, ce, race2, bel_com, clo_peo, com_comf, fam_help, fri_help, rel_stat, AGE)%>%
  filter(complete.cases(.))


sub3<-x38304_0001_Data%>%
  select(ho_suith, sex, ce, race2, bel_com, clo_peo, com_comf, fam_help, fri_help, rel_stat, AGE)%>%
  filter(complete.cases(.))
table1(~ sex + rel_stat + AGE + race2 + ce + bel_com + clo_peo + com_comf + fam_help + fri_help| sui_th, data=sub2, overall="Total")
## Warning in table1.formula(~sex + rel_stat + AGE + race2 + ce + bel_com + : Terms
## to the right of '|' in formula 'x' define table columns and are expected to be
## factors with meaningful labels.
0
(N=863)
1
(N=540)
Total
(N=1403)
sex
0 240 (27.8%) 198 (36.7%) 438 (31.2%)
1 623 (72.2%) 342 (63.3%) 965 (68.8%)
rel_stat
0 577 (66.9%) 332 (61.5%) 909 (64.8%)
1 286 (33.1%) 208 (38.5%) 494 (35.2%)
What is your age in years?
Mean (SD) 52.1 (12.5) 47.8 (13.8) 50.5 (13.2)
Median [Min, Max] 56.0 [18.0, 86.0] 51.5 [18.0, 78.0] 55.0 [18.0, 86.0]
race2
white 670 (77.6%) 397 (73.5%) 1067 (76.1%)
black 121 (14.0%) 78 (14.4%) 199 (14.2%)
other 72 (8.3%) 65 (12.0%) 137 (9.8%)
ce
1 487 (56.4%) 228 (42.2%) 715 (51.0%)
2 163 (18.9%) 115 (21.3%) 278 (19.8%)
3 99 (11.5%) 90 (16.7%) 189 (13.5%)
4 60 (7.0%) 66 (12.2%) 126 (9.0%)
5 54 (6.3%) 41 (7.6%) 95 (6.8%)
bel_com
agree 152 (17.6%) 213 (39.4%) 365 (26.0%)
disagree 557 (64.5%) 223 (41.3%) 780 (55.6%)
neutral 154 (17.8%) 104 (19.3%) 258 (18.4%)
clo_peo
agree 507 (58.7%) 227 (42.0%) 734 (52.3%)
disagree 161 (18.7%) 215 (39.8%) 376 (26.8%)
neutral 195 (22.6%) 98 (18.1%) 293 (20.9%)
com_comf
agree 487 (56.4%) 220 (40.7%) 707 (50.4%)
disagree 147 (17.0%) 193 (35.7%) 340 (24.2%)
neutral 229 (26.5%) 127 (23.5%) 356 (25.4%)
fam_help
agree 46 (5.3%) 58 (10.7%) 104 (7.4%)
disagree 672 (77.9%) 340 (63.0%) 1012 (72.1%)
neutral 145 (16.8%) 142 (26.3%) 287 (20.5%)
fri_help
agree 233 (27.0%) 69 (12.8%) 302 (21.5%)
disagree 290 (33.6%) 262 (48.5%) 552 (39.3%)
neutral 340 (39.4%) 209 (38.7%) 549 (39.1%)
cs1<-chisq.test(sub2$sui_th, sub2$sex, correct=FALSE)
cs2<-chisq.test(sub2$sui_th, sub2$rel_stat, correct=FALSE)
cs3<-chisq.test(sub2$sui_th, sub2$AGE, correct=FALSE)
## Warning in chisq.test(sub2$sui_th, sub2$AGE, correct = FALSE): Chi-squared
## approximation may be incorrect
cs4<-chisq.test(sub2$sui_th, sub2$race2, correct=FALSE)
cs5<-chisq.test(sub2$sui_th, sub2$ce, correct=FALSE)
cs6<-chisq.test(sub2$sui_th, sub2$bel_com, correct=FALSE)
cs7<-chisq.test(sub2$sui_th, sub2$clo_peo, correct=FALSE)
cs8<-chisq.test(sub2$sui_th, sub2$com_comf, correct=FALSE)
cs9<-chisq.test(sub2$sui_th, sub2$fam_help, correct=FALSE)
cs10<-chisq.test(sub2$sui_th, sub2$fri_help, correct=FALSE)


library(MASS)
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
summary(m1<-glm.nb(sui_th ~ ce, data=sub2))
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## 
## Call:
## glm.nb(formula = sui_th ~ ce, data = sub2, init.theta = 11909.94017, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.0235  -0.9096  -0.7986   0.7374   0.9610  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -1.14294    0.06623 -17.258  < 2e-16 ***
## ce2          0.26025    0.11438   2.275 0.022885 *  
## ce3          0.40100    0.12449   3.221 0.001277 ** 
## ce4          0.49631    0.13978   3.551 0.000384 ***
## ce5          0.30263    0.16964   1.784 0.074426 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(11909.94) family taken to be 1)
## 
##     Null deviance: 1031.2  on 1402  degrees of freedom
## Residual deviance: 1012.0  on 1398  degrees of freedom
## AIC: 2104
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  11910 
##           Std. Err.:  48207 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -2092.024
summary(m2<-glm.nb(sui_th ~ ce + sex + AGE + rel_stat + race2, data=sub2))
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## 
## Call:
## glm.nb(formula = sui_th ~ ce + sex + AGE + rel_stat + race2, 
##     data = sub2, init.theta = 11430.84889, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.2625  -0.8617  -0.7431   0.7165   1.1506  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)   
## (Intercept) -0.546498   0.204900  -2.667  0.00765 **
## ce2          0.199194   0.121009   1.646  0.09974 . 
## ce3          0.296736   0.132352   2.242  0.02496 * 
## ce4          0.459981   0.147599   3.116  0.00183 **
## ce5          0.321689   0.172882   1.861  0.06278 . 
## sex1        -0.251559   0.093398  -2.693  0.00707 **
## AGE         -0.008889   0.003431  -2.590  0.00959 **
## rel_stat1    0.107237   0.090308   1.187  0.23505   
## race2black  -0.078526   0.127198  -0.617  0.53700   
## race2other   0.084418   0.137726   0.613  0.53991   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(11430.85) family taken to be 1)
## 
##     Null deviance: 1031.15  on 1402  degrees of freedom
## Residual deviance:  991.08  on 1393  degrees of freedom
## AIC: 2093.1
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  11431 
##           Std. Err.:  44357 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -2071.123
summary(m3<-glm.nb(sui_th ~ ce + sex + AGE + rel_stat + race2 +bel_com +clo_peo + com_comf, data=sub2))
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## 
## Call:
## glm.nb(formula = sui_th ~ ce + sex + AGE + rel_stat + race2 + 
##     bel_com + clo_peo + com_comf, data = sub2, init.theta = 10309.38929, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4363  -0.7965  -0.6686   0.5896   1.3286  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)      -0.455392   0.222975  -2.042  0.04112 *  
## ce2               0.181193   0.120130   1.508  0.13148    
## ce3               0.344603   0.132596   2.599  0.00935 ** 
## ce4               0.488457   0.149023   3.278  0.00105 ** 
## ce5               0.326114   0.172848   1.887  0.05920 .  
## sex1             -0.230371   0.093706  -2.458  0.01395 *  
## AGE              -0.008702   0.003514  -2.476  0.01328 *  
## rel_stat1         0.019254   0.091185   0.211  0.83277    
## race2black       -0.027780   0.127767  -0.217  0.82787    
## race2other        0.097285   0.138038   0.705  0.48095    
## bel_comdisagree  -0.448587   0.115170  -3.895 9.82e-05 ***
## bel_comneutral   -0.212132   0.130387  -1.627  0.10375    
## clo_peodisagree   0.253675   0.145435   1.744  0.08111 .  
## clo_peoneutral   -0.012207   0.144098  -0.085  0.93249    
## com_comfdisagree  0.232755   0.147758   1.575  0.11520    
## com_comfneutral   0.035990   0.136741   0.263  0.79240    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(10309.39) family taken to be 1)
## 
##     Null deviance: 1031.15  on 1402  degrees of freedom
## Residual deviance:  925.47  on 1387  degrees of freedom
## AIC: 2039.5
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  10309 
##           Std. Err.:  36010 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -2005.52
summary(m4<-glm.nb(sui_th ~ ce + sex + AGE + rel_stat + race2 +fam_help + fri_help, data=sub2))
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## 
## Call:
## glm.nb(formula = sui_th ~ ce + sex + AGE + rel_stat + race2 + 
##     fam_help + fri_help, data = sub2, init.theta = 10264.19352, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4834  -0.8401  -0.6795   0.6416   1.4978  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)      -0.851814   0.253336  -3.362 0.000773 ***
## ce2               0.192521   0.120704   1.595 0.110716    
## ce3               0.271314   0.131878   2.057 0.039657 *  
## ce4               0.414396   0.149051   2.780 0.005432 ** 
## ce5               0.363034   0.173448   2.093 0.036345 *  
## sex1             -0.232166   0.093553  -2.482 0.013077 *  
## AGE              -0.008194   0.003477  -2.357 0.018427 *  
## rel_stat1         0.075912   0.090497   0.839 0.401561    
## race2black       -0.068052   0.127405  -0.534 0.593245    
## race2other        0.062883   0.137922   0.456 0.648442    
## fam_helpdisagree -0.326678   0.146417  -2.231 0.025672 *  
## fam_helpneutral  -0.111858   0.157855  -0.709 0.478565    
## fri_helpdisagree  0.721861   0.136623   5.284 1.27e-07 ***
## fri_helpneutral   0.529151   0.140288   3.772 0.000162 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(10264.19) family taken to be 1)
## 
##     Null deviance: 1031.2  on 1402  degrees of freedom
## Residual deviance:  949.1  on 1389  degrees of freedom
## AIC: 2059.2
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  10264 
##           Std. Err.:  36523 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -2029.157
summary(m5<-glm.nb(sui_th ~ ce + sex + AGE + rel_stat + race2 +bel_com +clo_peo + com_comf +fam_help + fri_help, data=sub2))
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## 
## Call:
## glm.nb(formula = sui_th ~ ce + sex + AGE + rel_stat + race2 + 
##     bel_com + clo_peo + com_comf + fam_help + fri_help, data = sub2, 
##     init.theta = 9661.53051, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4448  -0.7953  -0.6422   0.5402   1.5353  
## 
## Coefficients:
##                   Estimate Std. Error z value Pr(>|z|)   
## (Intercept)      -0.680346   0.263599  -2.581  0.00985 **
## ce2               0.177553   0.120207   1.477  0.13966   
## ce3               0.316409   0.132506   2.388  0.01695 * 
## ce4               0.440428   0.150022   2.936  0.00333 **
## ce5               0.340735   0.173486   1.964  0.04952 * 
## sex1             -0.221431   0.093702  -2.363  0.01812 * 
## AGE              -0.008532   0.003544  -2.407  0.01606 * 
## rel_stat1         0.012690   0.091476   0.139  0.88967   
## race2black       -0.018353   0.128003  -0.143  0.88599   
## race2other        0.094403   0.138296   0.683  0.49485   
## bel_comdisagree  -0.366784   0.116651  -3.144  0.00166 **
## bel_comneutral   -0.188558   0.130181  -1.448  0.14750   
## clo_peodisagree   0.237762   0.146660   1.621  0.10498   
## clo_peoneutral   -0.013488   0.144635  -0.093  0.92570   
## com_comfdisagree  0.179243   0.148949   1.203  0.22883   
## com_comfneutral  -0.005482   0.137698  -0.040  0.96824   
## fam_helpdisagree -0.222312   0.148241  -1.500  0.13370   
## fam_helpneutral  -0.074363   0.158512  -0.469  0.63898   
## fri_helpdisagree  0.454431   0.147139   3.088  0.00201 **
## fri_helpneutral   0.448788   0.141814   3.165  0.00155 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(9661.531) family taken to be 1)
## 
##     Null deviance: 1031.15  on 1402  degrees of freedom
## Residual deviance:  909.69  on 1383  degrees of freedom
## AIC: 2031.7
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  9662 
##           Std. Err.:  32278 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -1989.743
(est1<-cbind(Estimate = coef(m1), confint(m1)))
## Waiting for profiling to be done...
##               Estimate       2.5 %     97.5 %
## (Intercept) -1.1429369 -1.27561426 -1.0158855
## ce2          0.2602479  0.03306252  0.4818995
## ce3          0.4009996  0.15236357  0.6409991
## ce4          0.4963097  0.21496066  0.7638317
## ce5          0.3026321 -0.04359179  0.6231589
(est2<-cbind(Estimate = coef(m2), confint(m2)))
## Waiting for profiling to be done...
##                 Estimate       2.5 %       97.5 %
## (Intercept) -0.546498308 -0.95159139 -0.148294213
## ce2          0.199194227 -0.04077630  0.433987774
## ce3          0.296736464  0.03299213  0.552340897
## ce4          0.459981051  0.16403227  0.743476342
## ce5          0.321689122 -0.03036533  0.649088323
## sex1        -0.251559147 -0.43358175 -0.067255313
## AGE         -0.008888995 -0.01558878 -0.002134211
## rel_stat1    0.107236827 -0.07099545  0.283212024
## race2black  -0.078525841 -0.33447153  0.164797778
## race2other   0.084418451 -0.19378156  0.346947246
(est3<-cbind(Estimate = coef(m3), confint(m3)))
## Waiting for profiling to be done...
##                     Estimate       2.5 %      97.5 %
## (Intercept)      -0.45539212 -0.89647342 -0.02228130
## ce2               0.18119339 -0.05707396  0.41425777
## ce3               0.34460261  0.08038562  0.60068972
## ce4               0.48845745  0.18982633  0.77483573
## ce5               0.32611403 -0.02587924  0.65343849
## sex1             -0.23037103 -0.41299136 -0.04545908
## AGE              -0.00870180 -0.01556123 -0.00178230
## rel_stat1         0.01925395 -0.16065918  0.19698291
## race2black       -0.02778014 -0.28478097  0.21671710
## race2other        0.09728541 -0.18152071  0.36042598
## bel_comdisagree  -0.44858690 -0.67430691 -0.22271013
## bel_comneutral   -0.21213206 -0.47075846  0.04078194
## clo_peodisagree   0.25367495 -0.03111591  0.53883567
## clo_peoneutral   -0.01220654 -0.29764157  0.26747376
## com_comfdisagree  0.23275481 -0.05747843  0.52158012
## com_comfneutral   0.03598966 -0.23402178  0.30209894
(est4<-cbind(Estimate = coef(m4), confint(m4)))
## Waiting for profiling to be done...
##                      Estimate        2.5 %       97.5 %
## (Intercept)      -0.851813946 -1.355338122 -0.361843425
## ce2               0.192521314 -0.046853862  0.426720447
## ce3               0.271313892  0.008490799  0.525992473
## ce4               0.414395834  0.115626281  0.700733797
## ce5               0.363034358  0.009933408  0.691592383
## sex1             -0.232166312 -0.414480566 -0.047547832
## AGE              -0.008193967 -0.014981525 -0.001350445
## rel_stat1         0.075911904 -0.102696829  0.252251556
## race2black       -0.068052129 -0.324376322  0.175704662
## race2other        0.062882722 -0.215678271  0.325821401
## fam_helpdisagree -0.326677831 -0.605560769 -0.030578901
## fam_helpneutral  -0.111858025 -0.415468434  0.204539311
## fri_helpdisagree  0.721861413  0.460353994  0.996768498
## fri_helpneutral   0.529150991  0.259863027  0.810678136
(est5<-cbind(Estimate = coef(m5), confint(m5)))
## Waiting for profiling to be done...
##                      Estimate       2.5 %       97.5 %
## (Intercept)      -0.680345951 -1.20394265 -0.170230530
## ce2               0.177552726 -0.06085467  0.410780171
## ce3               0.316409053  0.05238659  0.572345712
## ce4               0.440428447  0.13984661  0.728753777
## ce5               0.340734563 -0.01242520  0.669383366
## sex1             -0.221431170 -0.40403448 -0.036519916
## AGE              -0.008531673 -0.01544919 -0.001553911
## rel_stat1         0.012689648 -0.16781017  0.190971723
## race2black       -0.018353484 -0.27578616  0.226638335
## race2other        0.094402718 -0.18488481  0.358070692
## bel_comdisagree  -0.366784101 -0.59567350 -0.138255744
## bel_comneutral   -0.188557876 -0.44679532  0.063940307
## clo_peodisagree   0.237762368 -0.04935095  0.525434583
## clo_peoneutral   -0.013488382 -0.29983708  0.267413025
## com_comfdisagree  0.179243348 -0.11327999  0.470471223
## com_comfneutral  -0.005481941 -0.27717795  0.262720624
## fam_helpdisagree -0.222311569 -0.50499627  0.077128059
## fam_helpneutral  -0.074362997 -0.37929751  0.243275141
## fri_helpdisagree  0.454430531  0.17151795  0.749042830
## fri_helpneutral   0.448787621  0.17634619  0.733132679
exp(est1)
##              Estimate     2.5 %    97.5 %
## (Intercept) 0.3188811 0.2792594 0.3620817
## ce2         1.2972517 1.0336152 1.6191471
## ce3         1.4933166 1.1645836 1.8983766
## ce4         1.6426483 1.2398131 2.1464852
## ce5         1.3534164 0.9573447 1.8648095
exp(est2)
##              Estimate     2.5 %    97.5 %
## (Intercept) 0.5789737 0.3861261 0.8621774
## ce2         1.2204190 0.9600439 1.5434000
## ce3         1.3454607 1.0335424 1.7373151
## ce4         1.5840440 1.1782523 2.1032344
## ce5         1.3794559 0.9700911 1.9137953
## sex1        0.7775875 0.6481833 0.9349565
## AGE         0.9911504 0.9845321 0.9978681
## rel_stat1   1.1131979 0.9314661 1.3273866
## race2black  0.9244782 0.7157162 1.1791546
## race2other  1.0880841 0.8238378 1.4147421
exp(est3)
##                   Estimate     2.5 %    97.5 %
## (Intercept)      0.6341992 0.4080060 0.9779651
## ce2              1.1986470 0.9445242 1.5132471
## ce3              1.4114289 1.0837049 1.8233760
## ce4              1.6298002 1.2090396 2.1702356
## ce5              1.3855734 0.9744528 1.9221387
## sex1             0.7942389 0.6616680 0.9555587
## AGE              0.9913360 0.9845592 0.9982193
## rel_stat1        1.0194405 0.8515823 1.2177232
## race2black       0.9726022 0.7521790 1.2419927
## race2other       1.1021749 0.8340010 1.4339401
## bel_comdisagree  0.6385298 0.5095094 0.8003468
## bel_comneutral   0.8088579 0.6245284 1.0416249
## clo_peodisagree  1.2887528 0.9693632 1.7140100
## clo_peoneutral   0.9878677 0.7425674 1.3066593
## com_comfdisagree 1.2620720 0.9441423 1.6846876
## com_comfneutral  1.0366451 0.7913446 1.3526951
exp(est4)
##                   Estimate     2.5 %    97.5 %
## (Intercept)      0.4266403 0.2578601 0.6963914
## ce2              1.2123023 0.9542268 1.5322243
## ce3              1.3116867 1.0085269 1.6921374
## ce4              1.5134561 1.1225763 2.0152309
## ce5              1.4376853 1.0099829 1.9968928
## sex1             0.7928143 0.6606834 0.9535649
## AGE              0.9918395 0.9851301 0.9986505
## rel_stat1        1.0788675 0.9024005 1.2869197
## race2black       0.9342118 0.7229781 1.1920859
## race2other       1.0649019 0.8059946 1.3851680
## fam_helpdisagree 0.7213161 0.5457683 0.9698839
## fam_helpneutral  0.8941712 0.6600310 1.2269597
## fri_helpdisagree 2.0582609 1.5846348 2.7095119
## fri_helpneutral  1.6974905 1.2967525 2.2494329
exp(est5)
##                   Estimate     2.5 %    97.5 %
## (Intercept)      0.5064418 0.3000090 0.8434703
## ce2              1.1942910 0.9409600 1.5079938
## ce3              1.3721914 1.0537831 1.7724198
## ce4              1.5533726 1.1500974 2.0724962
## ce5              1.4059800 0.9876517 1.9530326
## sex1             0.8013711 0.6676211 0.9641389
## AGE              0.9915046 0.9846695 0.9984473
## rel_stat1        1.0127705 0.8455143 1.2104252
## race2black       0.9818139 0.7589752 1.2543761
## race2other       1.0990022 0.8312000 1.4305667
## bel_comdisagree  0.6929592 0.5511912 0.8708759
## bel_comneutral   0.8281526 0.6396748 1.0660288
## clo_peodisagree  1.2684077 0.9518470 1.6911937
## clo_peoneutral   0.9866022 0.7409389 1.3065800
## com_comfdisagree 1.1963118 0.8929006 1.6007483
## com_comfneutral  0.9945331 0.7579196 1.3004633
## fam_helpdisagree 0.8006659 0.6035078 1.0801804
## fam_helpneutral  0.9283347 0.6843420 1.2754195
## fri_helpdisagree 1.5752761 1.1871055 2.1149747
## fri_helpneutral  1.5664119 1.1928509 2.0815914
des<-svydesign(ids= ~1, data=sub2)
## Warning in svydesign.default(ids = ~1, data = sub2): No weights or probabilities
## supplied, assuming equal probability
fit.logit1<-svyglm(sui_th ~ ce,
                    design = des, 
                   family=binomial)
fit.logit1%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3) 
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) -0.759 0.080 -9.454 0.000 0.468 0.400 0.548
ce2 0.410 0.146 2.811 0.005 1.507 1.132 2.006
ce3 0.664 0.166 3.989 0.000 1.942 1.402 2.690
ce4 0.854 0.196 4.366 0.000 2.350 1.601 3.448
ce5 0.484 0.222 2.176 0.030 1.622 1.049 2.507
fit.logit2<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2,
                    design = des, 
                   family=binomial)
fit.logit2%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)  
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) 0.338 0.274 1.234 0.217 1.402 0.820 2.397
ce2 0.314 0.157 1.994 0.046 1.369 1.005 1.864
ce3 0.498 0.174 2.869 0.004 1.645 1.171 2.312
ce4 0.811 0.204 3.970 0.000 2.249 1.507 3.356
ce5 0.520 0.227 2.290 0.022 1.683 1.078 2.627
sex1 -0.438 0.123 -3.557 0.000 0.646 0.507 0.822
rel_stat1 0.183 0.119 1.536 0.125 1.200 0.951 1.516
AGE -0.016 0.005 -3.592 0.000 0.984 0.975 0.993
race2black -0.126 0.162 -0.778 0.437 0.882 0.642 1.211
race2other 0.167 0.190 0.880 0.379 1.182 0.814 1.715
fit.logit3<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2 + bel_com,
                    design = des, 
                   family=binomial)
fit.logit3%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)  
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) 1.026 0.294 3.488 0.001 2.791 1.568 4.968
ce2 0.288 0.160 1.801 0.072 1.334 0.975 1.825
ce3 0.561 0.176 3.181 0.002 1.753 1.240 2.476
ce4 0.894 0.213 4.199 0.000 2.445 1.611 3.711
ce5 0.594 0.241 2.461 0.014 1.811 1.129 2.906
sex1 -0.444 0.127 -3.486 0.001 0.641 0.500 0.823
rel_stat1 0.079 0.122 0.645 0.519 1.082 0.851 1.375
AGE -0.014 0.005 -2.906 0.004 0.986 0.977 0.996
race2black -0.027 0.169 -0.162 0.871 0.973 0.698 1.355
race2other 0.256 0.198 1.293 0.196 1.292 0.876 1.905
bel_comdisagree -1.260 0.137 -9.184 0.000 0.284 0.217 0.371
bel_comneutral -0.748 0.171 -4.364 0.000 0.473 0.338 0.662
fit.logit4<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2 + clo_peo ,
                    design = des, 
                   family=binomial)
fit.logit4%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)  
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) 0.026 0.279 0.092 0.927 1.026 0.594 1.772
ce2 0.323 0.160 2.018 0.044 1.381 1.009 1.890
ce3 0.592 0.174 3.402 0.001 1.808 1.285 2.542
ce4 0.956 0.212 4.507 0.000 2.601 1.716 3.941
ce5 0.560 0.240 2.336 0.020 1.750 1.094 2.799
sex1 -0.456 0.128 -3.568 0.000 0.634 0.493 0.814
rel_stat1 0.072 0.123 0.584 0.559 1.075 0.844 1.369
AGE -0.018 0.005 -3.789 0.000 0.983 0.974 0.992
race2black -0.088 0.167 -0.528 0.598 0.916 0.660 1.270
race2other 0.158 0.195 0.811 0.418 1.171 0.799 1.715
clo_peodisagree 1.194 0.139 8.594 0.000 3.300 2.513 4.333
clo_peoneutral 0.224 0.152 1.479 0.139 1.251 0.930 1.684
fit.logit5<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2 + com_comf ,
                    design = des, 
                   family=binomial)
fit.logit5%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) 0.124 0.282 0.440 0.660 1.132 0.652 1.967
ce2 0.298 0.159 1.879 0.060 1.347 0.987 1.839
ce3 0.603 0.179 3.377 0.001 1.827 1.288 2.593
ce4 0.869 0.211 4.116 0.000 2.384 1.576 3.606
ce5 0.528 0.236 2.239 0.025 1.696 1.068 2.693
sex1 -0.456 0.127 -3.584 0.000 0.634 0.494 0.813
rel_stat1 0.081 0.123 0.663 0.507 1.085 0.853 1.380
AGE -0.019 0.005 -4.182 0.000 0.981 0.972 0.990
race2black -0.093 0.170 -0.548 0.584 0.911 0.653 1.271
race2other 0.171 0.192 0.890 0.374 1.186 0.815 1.727
com_comfdisagree 1.193 0.144 8.305 0.000 3.298 2.489 4.371
com_comfneutral 0.327 0.143 2.282 0.023 1.387 1.047 1.836
fit.logit6<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2 + fam_help ,
                    design = des, 
                   family=binomial)
fit.logit6%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)  
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) 0.666 0.327 2.037 0.042 1.946 1.026 3.692
ce2 0.294 0.160 1.845 0.065 1.342 0.982 1.835
ce3 0.459 0.174 2.640 0.008 1.583 1.126 2.226
ce4 0.748 0.208 3.597 0.000 2.113 1.406 3.177
ce5 0.507 0.227 2.230 0.026 1.660 1.063 2.592
sex1 -0.412 0.124 -3.320 0.001 0.662 0.519 0.845
rel_stat1 0.163 0.120 1.361 0.174 1.177 0.931 1.490
AGE -0.013 0.005 -2.845 0.005 0.987 0.978 0.996
race2black -0.100 0.164 -0.611 0.541 0.905 0.656 1.247
race2other 0.118 0.195 0.606 0.545 1.126 0.768 1.651
fam_helpdisagree -0.638 0.214 -2.980 0.003 0.528 0.347 0.804
fam_helpneutral -0.125 0.236 -0.530 0.596 0.883 0.556 1.401
fit.logit7<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2 + fri_help ,
                    design = des, 
                   family=binomial)
fit.logit7%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) -0.362 0.298 -1.215 0.225 0.696 0.389 1.249
ce2 0.328 0.158 2.070 0.039 1.388 1.018 1.894
ce3 0.503 0.175 2.869 0.004 1.654 1.173 2.333
ce4 0.836 0.206 4.059 0.000 2.308 1.541 3.456
ce5 0.652 0.239 2.728 0.006 1.920 1.201 3.068
sex1 -0.457 0.126 -3.628 0.000 0.633 0.495 0.811
rel_stat1 0.149 0.121 1.235 0.217 1.161 0.916 1.470
AGE -0.018 0.005 -3.976 0.000 0.982 0.973 0.991
race2black -0.144 0.163 -0.884 0.377 0.866 0.629 1.191
race2other 0.177 0.194 0.911 0.363 1.194 0.816 1.747
fri_helpdisagree 1.212 0.169 7.157 0.000 3.361 2.411 4.684
fri_helpneutral 0.802 0.170 4.732 0.000 2.231 1.600 3.110
fit.logit8<-svyglm(sui_th ~ ce + sex + rel_stat + AGE + race2 + bel_com + clo_peo + com_comf + fam_help + fri_help ,
                    design = des, 
                   family=binomial)
fit.logit8%>%
  tidy()%>%
  mutate(OR = exp(estimate),
         LowerOR_Ci = exp(estimate - 1.96*std.error),
         UpperOR_Ci = exp(estimate + 1.96*std.error))%>%
  knitr::kable(digits = 3)  
term estimate std.error statistic p.value OR LowerOR_Ci UpperOR_Ci
(Intercept) 0.303 0.362 0.837 0.403 1.354 0.666 2.753
ce2 0.282 0.162 1.739 0.082 1.326 0.965 1.823
ce3 0.568 0.178 3.201 0.001 1.766 1.247 2.501
ce4 0.861 0.216 3.979 0.000 2.366 1.548 3.616
ce5 0.633 0.258 2.451 0.014 1.884 1.135 3.126
sex1 -0.435 0.131 -3.319 0.001 0.647 0.501 0.837
rel_stat1 0.025 0.126 0.202 0.840 1.026 0.802 1.312
AGE -0.016 0.005 -3.247 0.001 0.985 0.975 0.994
race2black -0.028 0.170 -0.165 0.869 0.972 0.697 1.357
race2other 0.200 0.204 0.984 0.325 1.222 0.820 1.822
bel_comdisagree -0.686 0.163 -4.200 0.000 0.504 0.366 0.694
bel_comneutral -0.408 0.185 -2.212 0.027 0.665 0.463 0.955
clo_peodisagree 0.456 0.206 2.209 0.027 1.578 1.053 2.365
clo_peoneutral -0.031 0.187 -0.166 0.868 0.969 0.672 1.399
com_comfdisagree 0.352 0.208 1.692 0.091 1.422 0.946 2.139
com_comfneutral -0.019 0.184 -0.103 0.918 0.981 0.684 1.407
fam_helpdisagree -0.404 0.225 -1.798 0.072 0.668 0.430 1.037
fam_helpneutral -0.132 0.243 -0.543 0.587 0.876 0.544 1.412
fri_helpdisagree 0.701 0.189 3.712 0.000 2.015 1.392 2.917
fri_helpneutral 0.689 0.180 3.828 0.000 1.991 1.399 2.832
exp(coefficients(fit.logit1))
## (Intercept)         ce2         ce3         ce4         ce5 
##   0.4681725   1.5069691   1.9417863   2.3495614   1.6217511
exp(coefficients(fit.logit2))
## (Intercept)         ce2         ce3         ce4         ce5        sex1 
##   1.4018622   1.3689274   1.6452707   2.2493582   1.6827294   0.6456318 
##   rel_stat1         AGE  race2black  race2other 
##   1.2004409   0.9837617   0.8817692   1.1818669
exp(coefficients(fit.logit3))
##     (Intercept)             ce2             ce3             ce4             ce5 
##       2.7907205       1.3338974       1.7525508       2.4447243       1.8111557 
##            sex1       rel_stat1             AGE      race2black      race2other 
##       0.6413603       1.0820270       0.9862399       0.9729408       1.2919641 
## bel_comdisagree  bel_comneutral 
##       0.2837639       0.4732238
exp(coefficients(fit.logit4))
##     (Intercept)             ce2             ce3             ce4             ce5 
##       1.0260139       1.3810412       1.8075242       2.6006460       1.7499073 
##            sex1       rel_stat1             AGE      race2black      race2other 
##       0.6337559       1.0747493       0.9826166       0.9156004       1.1710239 
## clo_peodisagree  clo_peoneutral 
##       3.3000008       1.2513142
exp(coefficients(fit.logit5))
##      (Intercept)              ce2              ce3              ce4 
##        1.1320288        1.3474273        1.8272466        2.3842717 
##              ce5             sex1        rel_stat1              AGE 
##        1.6961503        0.6336929        1.0848659        0.9808189 
##       race2black       race2other com_comfdisagree  com_comfneutral 
##        0.9112508        1.1860376        3.2982910        1.3867000
exp(coefficients(fit.logit6))
##      (Intercept)              ce2              ce3              ce4 
##        1.9458011        1.3421685        1.5830597        2.1133527 
##              ce5             sex1        rel_stat1              AGE 
##        1.6600399        0.6623609        1.1773877        0.9868721 
##       race2black       race2other fam_helpdisagree  fam_helpneutral 
##        0.9047587        1.1257086        0.5284897        0.8825007
exp(coefficients(fit.logit7))
##      (Intercept)              ce2              ce3              ce4 
##        0.6964861        1.3881761        1.6542774        2.3079251 
##              ce5             sex1        rel_stat1              AGE 
##        1.9198682        0.6333058        1.1606444        0.9817046 
##       race2black       race2other fri_helpdisagree  fri_helpneutral 
##        0.8659415        1.1935727        3.3608391        2.2308313
exp(coefficients(fit.logit8))
##      (Intercept)              ce2              ce3              ce4 
##        1.3539488        1.3262324        1.7655231        2.3656526 
##              ce5             sex1        rel_stat1              AGE 
##        1.8838856        0.6474940        1.0256776        0.9845090 
##       race2black       race2other  bel_comdisagree   bel_comneutral 
##        0.9724453        1.2219277        0.5036831        0.6648530 
##  clo_peodisagree   clo_peoneutral com_comfdisagree  com_comfneutral 
##        1.5776886        0.9693194        1.4222967        0.9811431 
## fam_helpdisagree  fam_helpneutral fri_helpdisagree  fri_helpneutral 
##        0.6678743        0.8760653        2.0152414        1.9908295
library(ResourceSelection)
hl <- hoslem.test(sub2$sui_th, fitted(fit.logit1), g=10)
## Warning in hoslem.test(sub2$sui_th, fitted(fit.logit1), g = 10): The data did
## not allow for the requested number of bins.
hl
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit1)
## X-squared = 2.3388e-23, df = 1, p-value = 1
h2 <- hoslem.test(sub2$sui_th, fitted(fit.logit2), g=10)
h2
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit2)
## X-squared = 15.239, df = 8, p-value = 0.05466
h3 <- hoslem.test(sub2$sui_th, fitted(fit.logit3), g=10)
h3
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit3)
## X-squared = 11.996, df = 8, p-value = 0.1514
h4 <- hoslem.test(sub2$sui_th, fitted(fit.logit4), g=10)
h4
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit4)
## X-squared = 22.31, df = 8, p-value = 0.004374
h5 <- hoslem.test(sub2$sui_th, fitted(fit.logit5), g=10)
h5
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit5)
## X-squared = 15.677, df = 8, p-value = 0.04725
h6 <- hoslem.test(sub2$sui_th, fitted(fit.logit6), g=10)
h6
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit6)
## X-squared = 4.7126, df = 8, p-value = 0.7878
h7 <- hoslem.test(sub2$sui_th, fitted(fit.logit7), g=10)
h7
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit7)
## X-squared = 13.948, df = 8, p-value = 0.08314
h8 <- hoslem.test(sub2$sui_th, fitted(fit.logit8), g=10)
h8
## 
##  Hosmer and Lemeshow goodness of fit (GOF) test
## 
## data:  sub2$sui_th, fitted(fit.logit8)
## X-squared = 8.0808, df = 8, p-value = 0.4256
rg<-ref_grid(fit.logit7)
marg_logit<-emmeans(object = rg,
              specs = c( "ce",  "sex"),
             type="response" ,
              data=sub2)
knitr::kable(marg_logit,  digits = 4)
ce sex prob SE df asymp.LCL asymp.UCL
1 0 0.3691 0.0299 Inf 0.3127 0.4293
2 0 0.4481 0.0413 Inf 0.3693 0.5297
3 0 0.4918 0.0456 Inf 0.4036 0.5805
4 0 0.5745 0.0536 Inf 0.4677 0.6747
5 0 0.5290 0.0623 Inf 0.4075 0.6471
1 1 0.2703 0.0247 Inf 0.2247 0.3214
2 1 0.3396 0.0322 Inf 0.2795 0.4053
3 1 0.3800 0.0397 Inf 0.3058 0.4602
4 1 0.4609 0.0484 Inf 0.3685 0.5561
5 1 0.4156 0.0553 Inf 0.3128 0.5263
rg<-ref_grid(fit.logit7)
marg_logit<-emmeans(object = rg,
              specs = c( "ce",  "fri_help"),
             type="response" ,
              data=sub2)
knitr::kable(marg_logit,  digits = 4)
ce fri_help prob SE df asymp.LCL asymp.UCL
1 agree 0.1921 0.0270 Inf 0.1447 0.2506
2 agree 0.2482 0.0353 Inf 0.1856 0.3235
3 agree 0.2824 0.0422 Inf 0.2073 0.3718
4 agree 0.3544 0.0540 Inf 0.2569 0.4656
5 agree 0.3135 0.0558 Inf 0.2155 0.4315
1 disagree 0.4442 0.0301 Inf 0.3863 0.5037
2 disagree 0.5260 0.0391 Inf 0.4493 0.6015
3 disagree 0.5694 0.0431 Inf 0.4837 0.6511
4 disagree 0.6485 0.0481 Inf 0.5496 0.7361
5 disagree 0.6055 0.0585 Inf 0.4870 0.7127
1 neutral 0.3466 0.0284 Inf 0.2932 0.4042
2 neutral 0.4241 0.0386 Inf 0.3508 0.5010
3 neutral 0.4674 0.0436 Inf 0.3837 0.5530
4 neutral 0.5505 0.0504 Inf 0.4511 0.6460
5 neutral 0.5046 0.0596 Inf 0.3896 0.6191