Displaying 1 result from an estimated 1 matches for "carrot0".
Did you mean:
carrot
2008 May 08
2
poisson regression with robust error variance ('eyestudy
...exactly, but the robust standard errors are a bit off.
### Paul Johnson 2008-05-08
### sandwichGLM.R
system("wget http://www.ats.ucla.edu/stat/stata/faq/eyestudy.dta")
library(foreign)
dat <- read.dta("eyestudy.dta")
### Ach, stata codes factor contrasts backwards
dat$carrot0 <- ifelse(dat$carrot==0,1,0)
dat$gender1 <- ifelse(dat$gender==1,1,0)
glm1 <- glm(lenses~carrot0, data=dat, family=poisson(link=log))
summary(glm1)
library(sandwich)
vcovHC(glm1)
sqrt(diag(vcovHC(glm1)))
sqrt(diag(vcovHC(glm1, type="HC0")))
### Result:
# > summary(gl...