如何解决计算赔率变化,并用R进行伪R平方
我有一个涉及R和统计技术解决方案的问题。我希望它不太统计,并且仍然与此网站相关。我有一个庞大的数据集,共有2400名受访者。为了分析不同社会经济群体对地方政府腐败的看法,我进行了逻辑回归。受访者可以说“不是很多/几乎没有任何腐败的官员”或“大多数/每个官员都是腐败的”。
我现在正在寻找一种方法来计算当地官员大多是腐败的可能性的变化。所以我可以说,认为腐败在男性而非女性中普遍存在的可能性降低了x%。
除此之外,我想为每个预测变量计算Pseudo-R-Squared,并控制其他变量。我知道如何在SPSS中执行此操作,但是在R中手动计算该值似乎更高级。
这是我的模型,其中“没有很多/几乎没有腐败的官员”作为因变量的参考类别。性别的参考类别是女性,教育的参考类别是基础教育。
glm(formula = corruption_local_recoded ~ gender + age + education_cat,family = binomial(link = "logit"),data = lebanon,subset = (corruption_local_recoded !=
"Don't know" & education_cat != "No formal education"))
Deviance Residuals:
Min 1Q Median 3Q Max
-1.671 -1.290 0.896 1.017 1.468
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.274611 0.169750 7.509 5.97e-14 ***
genderMale 0.169807 0.085740 1.980 0.047650 *
age -0.018510 0.002972 -6.228 4.74e-10 ***
education_catSecondary education -0.217526 0.107645 -2.021 0.043302 *
education_catHigher education -0.402557 0.121817 -3.305 0.000951 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 3139 on 2327 degrees of freedom
Residual deviance: 3095 on 2323 degrees of freedom
(42 observations deleted due to missingness)
AIC: 3105
Number of Fisher Scoring iterations: 4
这是我的数据集中前250行的示例:
structure(list(age = c(41L,36L,33L,26L,28L,31L,45L,70L,18L,23L,20L,24L,44L,38L,39L,54L,22L,62L,67L,40L,53L,58L,52L,43L,29L,21L,41L,37L,48L,65L,59L,75L,32L,63L,68L,34L,56L,30L,60L,25L,66L,19L,55L,49L,47L,71L,27L,72L,35L,50L,57L,61L,42L,46L,69L,48L),gender = c("Male","Female","Male","Female"),education_cat = structure(c(2L,2L,3L,4L,1L,2L),.Label = c("No formal education","Basic education","Secondary education","Higher education"),class = "factor"),corruption_local_recoded = structure(c(1L,NA,.Label = c("Not a lot/hardly any corrupt official","Most/every official is corrupt","Don't know","Refused to answer"
),class = "factor")),row.names = c(NA,250L),class = "data.frame")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。