簡體   English   中英

Residual(model) Diagnostics for within-between regression model using wbm() function of panelr package in R

[英]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 中安裝帶有betaregr ,下面的代碼塊給了我下面的圖

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM