估计和绘制具有交互作用项的polr模型的预测概率

时间:2019-04-23 20:07:00

标签: r probability logistic-regression

我已经估计了带有交互作用项的polr模型,并希望计算和绘制相关的预测概率。 polr模型自然是有序logit。如何计算和绘制polr模型的预测概率?

我已经尝试过效果包,但是会产生一些错误。我目前在该软件包中收到“ x0%*%b中的错误:参数不一致”。出于这个原因,因为我想对特效图进行更多自定义,所以我尝试使用“预测”代替。不幸的是,我在网上找到的所有有关如何使用它的示例都是基于具有数值的预测变量(独立变量)。我所有的自变量都具有分类值,因此对我没有太大帮助。

这是我用于模型的代码

ologit= polr(var1 ~   var2 + var3 + var4*var5 + var6 + var7 + var8 + var9,  data = my.data2, method="logistic", Hess=TRUE,na.action = na.omit)
summary(ologit)

我对计算和绘制var4和var5相互作用的预测概率感兴趣。

这是ologit模型的摘要:


Call:
polr(formula = var1 ~ var2 + var3 + var4 * var5 + var6 + var7 + 
    var8 + var9, data = my.data2, na.action = na.omit, Hess = TRUE, 
    method = "logistic")

Coefficients:
                                            Value Std. Error    t value
var2(2) Second quintile                   0.07431  2.991e-02  2.485e+00
var2(3) Third quintile                    0.09600  3.015e-02  3.184e+00
var2(4) Fourth quintile                   0.03727  2.887e-02  1.291e+00
var2(5) Fifth quintile                    0.07389  2.709e-02  2.728e+00
var3Elementary and Primary                0.10274  2.916e-02  3.523e+00
var3Secondary                             0.13608  2.618e-02  5.198e+00
var3Undergraduate Degree                  0.20229  2.910e-02  6.953e+00
var3Graduate Degree                       0.18731  1.521e-02  1.231e+01
var4(2) 25-34                            -0.12703  2.669e-02 -4.760e+00
var4(3) 35-44                            -0.11162  2.656e-02 -4.203e+00
var4(4) 45-54                            -0.11464  3.055e-02 -3.753e+00
var4(5) 55-64                            -0.32372  3.737e-02 -8.663e+00
var4(6) 65-74                             0.08027  2.388e-02  3.362e+00
var4(7) 75 and over                       0.86848  2.511e-03  3.459e+02
var5(2) Agree                            -0.12495  1.858e-02 -6.724e+00
var5(3) Disagree                         -0.09071  1.775e-02 -5.109e+00
var5(4) Strongly Disagree                -1.05268  3.371e-05 -3.123e+04
var6(2) Female                            0.03721  3.124e-02  1.191e+00
var7(2) Christian                        -0.81196  2.068e-02 -3.927e+01
var7(5) Jew                              -1.03246  8.974e-04 -1.151e+03
var7(7) Other                            -1.46649  4.586e-04 -3.197e+03
var8Jordan                                0.86871  4.877e-02  1.781e+01
var8Palestine                             1.17001  2.833e-02  4.129e+01
var8Algeria                               1.05690  4.801e-02  2.201e+01
var8Morocco                               0.73853  4.498e-02  1.642e+01
var8Lebanon                              -0.68778  3.684e-02 -1.867e+01
var8Yemen                                 1.27596  1.249e-02  1.021e+02
var8Iraq                                  0.19942  3.810e-02  5.234e+00
var8Egypt                                -0.08264  1.064e-02 -7.770e+00
var8Saudi Arabia                          1.45546  7.409e-03  1.965e+02
var8Sudan                                 1.23165  1.897e-02  6.492e+01
var9                                     -0.09801  1.868e-05 -5.246e+03
var4(2) 25-34:var5(2) Agree               0.09911  3.119e-02  3.177e+00
var4(3) 35-44:var5(2) Agree               0.13061  3.173e-02  4.116e+00
var4(4) 45-54:var5(2) Agree               0.08699  3.322e-02  2.619e+00
var4(5) 55-64:var5(2) Agree               0.22860  2.483e-02  9.206e+00
var4(6) 65-74:var5(2) Agree              -0.05372  1.733e-02 -3.101e+00
var4(7) 75 and over:var5(2) Agree        -0.16334  1.539e-03 -1.061e+02
var4(2) 25-34:var5(3) Disagree            0.29210  3.388e-02  8.620e+00
var4(3) 35-44:var5(3) Disagree            0.19224  3.372e-02  5.700e+00
var4(4) 45-54:var5(3) Disagree            0.26272  3.452e-02  7.610e+00
var4(5) 55-64:var5(3) Disagree            0.53459  1.223e-02  4.370e+01
var4(6) 65-74:var5(3) Disagree           -0.22585  5.530e-03 -4.084e+01
var4(7) 75 and over:var5(3) Disagree     -0.90162  9.245e-04 -9.753e+02
var4(3) 35-44:var5(4) Strongly Disagree -62.42834  7.864e-32 -7.938e+32
var4(4) 45-54:var5(4) Strongly Disagree  23.08992  1.344e-13  1.718e+14

Intercepts:
                                            Value         Std. Error    t value      
(1) Strongly Agree|(2) Agree                -1.973271e+02  1.700000e-03 -1.150305e+05
(2) Agree|(3) Neither Agree nor Disagree    -1.957070e+02  2.150000e-02 -9.084325e+03
(3) Neither Agree nor Disagree|(4) Disagree -1.957070e+02  2.150000e-02 -9.084325e+03
(4) Disagree|(5) Strongly Disagree          -1.941313e+02  2.950000e-02 -6.578053e+03

Residual Deviance: 36595.70 
AIC: 36695.70 

我想要一种方法来理想地预测概率,然后使用ggplot以可自定义的方式绘制它们。

不用说,任何帮助将不胜感激。感谢您的考虑!

0 个答案:

没有答案