[英]Residual(model) Diagnostics for within-between regression model using wbm() function of panelr package in R
I am using the wbm()
from the panelr package by Prof Long ( https://panelr.jacob-long.com/articles/wbm.html ) to fit a within-between (mixed-effects) model.
我想了解如何进行残差或 model 诊断。 例如,在 r 中安装带有betareg
的r
,下面的代码块给了我下面的图
par(mfrow=c(3,2))
plot(fit1, which = 1:4, type = "pearson")
plot(fit1, which = 5, type = "deviance", sub.caption = "")
plot(fit1, which = 1, type = "deviance", sub.caption = "")
但是当我使用wbm()
运行回归(名为 fit3 的模型)并运行代码以获取诊断图时
par(mfrow=c(3,2))
plot(fit3, which = 1:4, type = "pearson")
plot(fit3, which = 5, type = "deviance", sub.caption = "")
plot(fit3, which = 1, type = "deviance", sub.caption = "")
编辑以下是基于 package 数据的 MWE:
#Load Package
library(panelr)
#Load teen_poverty data from package
data("WageData")
head(WageData)
#Declare data as panel
Wages <- panel_data(WageData, id = id, wave = t)
Wages
#Run a "contextual" model
fit3 <- wbm(lwage ~ wks + union + ms + occ | blk + fem, data = Wages, model = "contextual")
summary(fit3)
#Model/Residual Diagnostics
par(mfrow=c(3,2))
plot(fit3, which = 1:4, type = "pearson")
plot(fit3, which = 5, type = "deviance", sub.caption = "")
plot(fit3, which = 1, type = "deviance", sub.caption = "")
如果有人可以帮助指导我在使用wbm()
运行 model 时如何获得适当的绘图,我将不胜感激?
谢谢你。
以下是制作每个图的方法:
## Residuals vs index:
plot(residuals(fit3))
## Cook's Distance
plot(cooks.distance(fit3), type="n")
cdist <- cooks.distance(fit3)
segments(1:length(cdist), 0, 1:length(cdist), cdist)
## leverage vs fitted
plot(fitted(fit3), hatvalues(fit3))
## residuals vs linear predictor
plot(fitted(fit3), residuals(fit3))
## normal quantiles
qqnorm(residuals(fit3))
## or
car::qqPlot(residuals(fit3))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.