在绘制有序逻辑回归的效果时如何在plot_model中重新排序阶乘项(MASS中的polr函数)

时间:2019-04-22 12:16:40

标签: r ggplot2 plot

我正在使用sjplot plot_model函数绘制有序逻辑回归的效果。

用于拟合模型的代码:

mult_4_rank_best <- polr(SpRank ~ RodentRank + SpName + day_start_scale + Lat_scale +
                           Lon2_scale + Lon_scale + RodentRank:SpName + 
                           day_start_scale:SpName + Lon2_scale:SpName + 
                           Lon_scale:SpName + RodentRank:SpName:day_start_scale, 
                         data = data_mult,
                         na.action = na.pass, 
                         Hess = TRUE)

尽管有很多预测变量,但我想查看Rodent Rank和SpName对结果的影响并使用此代码:

plot_model(mult_4_rank_best, type = "eff", terms = c("RodentRank", "SpName"))

尽管事实是数据集中的变量在拟合模型之前已按照这种方式排序

data_mult$RodentRank <- factor(data_mult$RodentRank, 
                               levels = c("low", "average", "high"), 
                               ordered=TRUE)

我不断得到结果图片,其中RodentRank的级别按字母顺序排列。 order.terms = c()没有帮助。

我无法在Google上找到此问题的答案。如果有人对如何使用它有所了解,我将不胜感激。

0 个答案:

没有答案