I am trying to replicate a Stata Output in R. I am using the dataset affairs. I am having trouble replicating the probit function with robust standard errors.
The Stata code looks like that:
probit affair male age yrsmarr kids relig educ ratemarr, r
I've started with:
probit1 <- glm(affair ~ male + age + yrsmarr + kids + relig + educ + ratemarr,
family = binomial (link = "probit"), data = mydata)
Then I've tried various adjustments with the sandwich
package, such as:
myProbit <- function(probit1, vcov = sandwich(..., adjust = TRUE)) {
print(coeftest(probit1, vcov = sandwich(probit1, adjust = TRUE)))
}
Or (with all types HC0
to HC5
):
myProbit <- function(probit1, vcov = sandwich) {
print(coeftest(probit1, vcovHC(probit1, type = "HC0"))
}
Or this, as was suggested here (do I have to enter something different for object
?):
sandwich1 <- function(object, ...) sandwich(object) * nobs(object) / (nobs(object) - 1)
coeftest(probit1, vcov = sandwich1)
None of these attempts led to the same standard errors or z-values from the stata output.
Hoping for some constructive ideas!
Thanks in advance!
sandwich1
method works for the standard errors in the logit-Regression using the same data but I couldn't manage to get the correct chi2 with it. Any ideas on why that may be? – Defeatistwaldtest()
function from thelmtest
package or thelinearHypothesis()
function from thecar
package. Both allow for optionalvcov
arguments to be plugged in. – Tranquilize