8

I am running the linear regression models using generalized estimating equation with geepack. The confint(fit) command does not seem to work in here. For example:

f2 <- geeglm(FEV1 ~ Age, data = Hospdata, family=gaussian, id=HHID)  
summary(f2)
confint(f2)

I get the following error message in running confint(f2):

> confint(f2)
Waiting for profiling to be done...
Error in `[.data.frame`(summ$coefficients, , "Std. Error", drop = FALSE) : undefined columns selected

Is there any way to find the confidence interval in here?

XTL
  • 851
  • 1
  • 8
  • 23
mani
  • 251
  • 2
  • 6
  • 9

4 Answers4

18

Something like this:

library(geepack)
data(dietox)
dietox$Cu     <- as.factor(dietox$Cu)
mf1 <- formula(Weight~Cu*poly(Time,3))
gee1 <- geeglm(mf1, data=dietox, id=Pig,
               family=poisson("identity"),corstr="ar1")
cc <- coef(summary(gee1))
citab <- with(as.data.frame(cc),
     cbind(lwr=Estimate-1.96*Std.err,
           upr=Estimate+1.96*Std.err))
rownames(citab) <- rownames(cc)

For convenience, you could write a confint method that encapsulates this:

confint.geeglm <- function(object, parm, level = 0.95, ...) {
    cc <- coef(summary(object))
    mult <- qnorm((1+level)/2)
    citab <- with(as.data.frame(cc),
                  cbind(lwr=Estimate-mult*Std.err,
                        upr=Estimate+mult*Std.err))
    rownames(citab) <- rownames(cc)
    citab[parm,]
}

confint(gee1)
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Thanks - if I understand correctly, this relies on the assumption of a Gaussian (normal) distribution of the estimate. May I ask you to confirm that this is indeed the case, possibly with a reference? This would help me a lot to actually use it for my research analysis. – Martin Sep 06 '20 at 23:13
  • 1
    yes, that's a Wald confidence interval (assumes normal sampling distribution of the estimate) – Ben Bolker Sep 06 '20 at 23:23
  • Fantastic, thanks for the really fast answer and directing me to the Wald confidence intervals. – Martin Sep 07 '20 at 00:18
2

Simply broom:tidy(f2, conf.int = TRUE)

its.me.adam
  • 333
  • 2
  • 11
0

confint is from the stats package. geeglm is from the geepack package.

You need to determine where the confident intervals are stored in the model output.

Use str(f2) or derive them from summary(f2).

Also have a look at f2$ and tab to auto-complete through the model objects.

Also, also - look in the documentation - link. You may have to construct your own as the example model I ran did not generate CIs. You may have to hand roll them from parameter standard errors.

John
  • 41,131
  • 31
  • 82
  • 106
0

It's four years on and I arrived here for the same reason. For the benefit of others who also arrive here, after seeing Ben's reply above, I realised that the confint() function computes profile likelihood intervals. It won't work with a GEE, because it isn't based on a likelihood.

The base function confint.default() gives Wald intervals and can be used with a GEE. It should give the same results as Ben's function above.