我试图用r中的交互项来描绘障碍回归输出,但是在使用模型的计数部分时遇到了一些麻烦。
Model <- hurdle(Suicide. ~ Age + gender + bullying*support, dist = "negbin", link = "logit")
由于我不知道任何方法可以让我在不分别估算每个部分的情况下绘制这些数据(二项式logit和负二项式计数),我试图使用MASS包使用估计来绘制每个部分。到目前为止,我使用visreg包进行绘图时运气最好,但我对其他建议持开放态度。我已经能够重现并成功绘制障碍模型的原始逻辑输出,但不是负二项计数数据(即,MASS的参数估计与障碍回归输出中的参数估计不同)。
我非常感谢有关其他人如何在过去绘制障碍回归结果的任何见解,或者我如何能够在MASS中使用glm.nb重现最初从障碍模型中获得的负二项式系数。
以下是我用来绘制数据的内容:
##Logistic
logistic<-glm(SuicideBinary ~ Age + gender + bullying*support, data = sx, family="binomial")
data("sx", package = "MASS")
##Linear scale
visreg(logistic, "bullying", by="support", xlab = "bullying", ylab = "Log odds (Suicide yes/no)")
##Logistic/probability scale
visreg(logistic, "bullying", by="support", scale = "response", xlab = "bullying", ylab = "P(Initial Attempt)")
##Count model
NegBin<-glm.nb(Suicide. ~ Age + gender + bullying*support, data = sx)
data("sx", package = "MASS")
##Linear scale
visreg(NegBin, "bullying", by="support", xlab = "bullying", ylab = "Count model (number of suicide attempts)")
##Logistic/probability scale
visreg(NegBin, "bullying", by="support", scale = "response", xlab = "bullying", ylab = "P(Subsequent Attempts)")