data("MockJurors", package = "betareg")
library("lmtest")
## Smithson & Verkuilen (2006, Table 1)
## variable dispersion model
## (NOTE: numerical rather than analytical Hessian is used for replication,
## Smithson & Verkuilen erroneously compute one-sided p-values)
mj_vd <- betareg(confidence ~ verdict * conflict | verdict * conflict,
data = MockJurors, hessian = TRUE)
summary(mj_vd)
## model selection for beta regression: null model, fixed dispersion model (p. 61)
mj_null <- betareg(confidence ~ 1 | 1, data = MockJurors)
mj_fd <- betareg(confidence ~ verdict * conflict | 1, data = MockJurors)
lrtest(mj_null, mj_fd)
lrtest(mj_null, mj_vd)
## McFadden's pseudo-R-squared
1 - as.vector(logLik(mj_null)/logLik(mj_vd))
## visualization
if(require("lattice")) {
histogram(~ confidence | conflict + verdict, data = MockJurors,
col = "lightgray", breaks = 0:10/10, type = "density")
}
## see demo("SmithsonVerkuilen2006", package = "betareg") for more details
Run the code above in your browser using DataLab