0

The poisson regression looks as follows in My R-code:

poissmod <- glm(aerobics$y ~ factor(aerobics$x1) + factor(aerobics$x2) + aerobics$x3 + aerobics$x4, family = poisson)
poissmod

Now I have to compute a confidence interval for the factor aerobics$x1 (in a model without aerobics$x1 since this is not significant).

This might look very easy, but I am not familiar with R and I can 't find the answer anywhere...

Anyone who can help me?

Thanks a lot in advance!

majom
  • 7,863
  • 7
  • 55
  • 88
user3387899
  • 601
  • 5
  • 18

1 Answers1

2

See e.g. the confint function in the MASS package (http://stat.ethz.ch/R-manual/R-devel/library/MASS/html/confint.html):

ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive = 20 - numdead)
budworm.lg0 <- glm(SF ~ sex + ldose - 1, family = binomial)
confint(budworm.lg0)
confint(budworm.lg0, "ldose")

The example is for a logistic regression, but this will also work for a poisson regression.

Here is another example from the stats package documentation for a poisson regression (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/confint.html):

## from example(glm)
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3, 1, 9); treatment <- gl(3, 3)
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
confint(glm.D93) # needs MASS to be present on the system
confint.default(glm.D93)  # based on asymptotic normality
majom
  • 7,863
  • 7
  • 55
  • 88
  • Thank you for the answer. I already tried it that way, giving following R-code: confint(poissmod2, 'aerobics$x1', level=0.95). I, however, get an error: argument is of lenght zero... – user3387899 Mar 06 '14 at 12:33
  • Welcome to SO. The commands basically work. If there is some other problem with your code, I could help if you would provide a reproducible example. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – majom Mar 06 '14 at 12:36
  • Well, the code does not seem to work for me... I keep getting the error: 'argument is of lenght zero'. So there is still something wrong with my code? – user3387899 Mar 06 '14 at 12:40
  • It would be helpful if you could post a reproducible toy example where this error occurs. – majom Mar 06 '14 at 12:51
  • I am sorry, I'm not really familiar with R and I don't know what you mean with a reproducible toy example :-) – user3387899 Mar 06 '14 at 12:55
  • Please read the post, which I have linked in my first comment. It outlines in great detail what you should do. – majom Mar 06 '14 at 12:57
  • @user3387899 : does `confint(poissmod2)` not give you a value for `x1`? Alternately, you should try `aerobics <- transform(aerobics, x1=factor(x1), x2=factor(x2)); poissmod <- glm(y ~ x1 + x2 + x3 + x4, data = aerobics, family = poisson); confint(poissmod, "x1")` – Ben Bolker Mar 10 '14 at 12:41