R 二元logistic随机斜率模型的可视化

R 二元logistic随机斜率模型的可视化,r,ggplot2,mlogit,R,Ggplot2,Mlogit,我使用以下数据运行了二元逻辑随机斜率模型: serve country conscription sex education income religion immigrant proud trusting outgoing age 1 Yes ALG 1 male 3 5 Very important 0 1 2 2 -15.7403

我使用以下数据运行了二元逻辑随机斜率模型:

 serve country conscription    sex education income         religion immigrant proud trusting outgoing         age
1    Yes     ALG            1   male         3      5   Very important         0     1        2        2 -15.7403361
2    Yes     ALG            1 female         3      6 Rather important         0     2        4        2 -12.7403361
3    Yes     ALG            1 female         3      6   Very important         0     1        3        3 -10.7403361
4    Yes     ALG            1 female         3      5   Very important         0     1        3        4  -8.7403361
5    Yes     ALG            1 female         2      7   Very important         0     1        4        4  -1.7403361
6    Yes     ALG            1   male         4      5   Very important         0     1        3        4  -0.7403361
7    Yes     ALG            1   male         3      7   Very important         0     1        2        2   4.2596639
8    Yes     ALG            1 female         2      2 Rather important         0     1        3        4   7.2596639
9    Yes     ALG            1   male         1      5 Rather important         0     1        3        2  22.2596639
11   Yes     ALG            1 female         4      5   Very important         0     1        3        1 -13.7403361
模型如下所示:

Generalized linear mixed model fit by maximum likelihood (Adaptive Gauss-Hermite Quadrature, nAGQ = 0) ['glmerMod']
 Family: binomial  ( logit )
Formula: serve ~ age + sex + income + religion + proud + trusting + outgoing +      conscription + (1 + proud | country)
   Data: WVS.2
Control: glmerControl(optimizer = "bobyqa")

     AIC      BIC   logLik deviance df.resid 
 26133.6  26359.2 -13038.8  26077.6    23283 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.5789 -0.9022  0.4386  0.6850  3.5584 

Random effects:
 Groups  Name        Variance Std.Dev. Corr             
 country (Intercept) 0.70584  0.8401                    
         proud2      0.05847  0.2418   -0.31            
         proud3      0.18141  0.4259   -0.37  0.79      
         proud4      0.75998  0.8718    0.14  0.58  0.81
Number of obs: 23311, groups:  country, 20

Fixed effects:
                          Estimate Std. Error z value Pr(>|z|)    
(Intercept)               0.139479   0.248397   0.562  0.57444    
age                      -0.006126   0.001319  -4.645 3.40e-06 ***
sexmale                   0.652698   0.030950  21.089  < 2e-16 ***
income                   -0.006549   0.007549  -0.867  0.38569    
religionRather important  0.146834   0.053087   2.766  0.00568 ** 
religionVery important    0.299748   0.051477   5.823 5.78e-09 ***
proud2                   -0.178368   0.066784  -2.671  0.00757 ** 
proud3                   -0.340180   0.117835  -2.887  0.00389 ** 
proud4                   -0.346386   0.245852  -1.409  0.15886    
trusting2                 0.105620   0.057906   1.824  0.06815 .  
trusting3                 0.173238   0.058896   2.941  0.00327 ** 
trusting4                 0.338042   0.057763   5.852 4.85e-09 ***
trusting5                 0.281655   0.063626   4.427 9.57e-06 ***
outgoing2                -0.170605   0.065585  -2.601  0.00929 ** 
outgoing3                -0.110182   0.065934  -1.671  0.09470 .  
outgoing4                 0.117553   0.063268   1.858  0.06317 .  
outgoing5                 0.218266   0.067077   3.254  0.00114 ** 
conscription1             0.023910   0.338071   0.071  0.94362    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
广义线性混合模型最大似然拟合(自适应高斯-厄米特求积,nAGQ=0)['glmerMod']
家庭:二项式(logit)
公式:服役~年龄+性别+收入+宗教+骄傲+信任+外出+征兵+(1+骄傲|国家)
数据:WVS.2
控件:glmerControl(optimizer=“bobyqa”)
AIC BIC logLik偏差df.resid
26133.6  26359.2 -13038.8  26077.6    23283 
标度残差:
最小1季度中值3季度最大值
-4.5789 -0.9022  0.4386  0.6850  3.5584 
随机效应:
组名为Variance Std.Dev。科尔
国家(截距)0.70584 0.8401
proud2 0.05847 0.2418-0.31
proud3 0.18141 0.4259-0.37 0.79
proud4 0.75998 0.8718 0.14 0.58 0.81
OB数量:23311,组:国家,20
固定效果:
估计标准误差z值Pr(>z)
(截距)0.139479 0.248397 0.562 0.57444
年龄-0.006126 0.001319-4.645 3.40e-06***
性别男性0.652698 0.030950 21.089<2e-16***
收入-0.006549 0.007549-0.867 0.38569
宗教领袖重要人物0.146834 0.053087 2.766 0.00568**
宗教重要0.299748 0.051477 5.823 5.78e-09***
proud2-0.178368 0.066784-2.671 0.00757**
proud3-0.340180 0.117835-2.887 0.00389**
proud4-0.346386 0.245852-1.409 0.15886
信任2 0.105620 0.057906 1.824 0.06815。
信任3 0.173238 0.058896 2.941 0.00327**
信任4 0.338042 0.057763 5.852 4.85e-09***
信任5 0.281655 0.063626 4.427 9.57e-06***
支出2-0.170605 0.065585-2.601 0.00929**
支出3-0.110182 0.065934-1.671 0.09470。
支出4 0.117553 0.063268 1.858 0.06317。
支出5 0.218266 0.067077 3.254 0.00114**
征兵1 0.023910 0.338071 0.071 0.94362
---
签名。代码:0'***'0.001'***'0.01'*'0.05'.'0.1''1
我希望能够将其可视化,使其看起来像本页上的第一个情节:

我可以像第一步一样创建新的数据帧

df1 <- dplyr::select(WVS.2, country, proud, serve)
df1$age <- 0
df1$sex <- 0
df1$income <- 0
df1$religion <- 0
df1$trusting <- 0
df1$outgoing <- 0
df1$conscription <- 0
df1