Reputation: 7832
Note: This is a cross posting. I posted this question last week on Cross Validated, however, it either doesn't fit in there or it wasn't recognized - hence, I'm trying to get an answer here...
When I run a glm
with binomial-family (logistic regression), R output gives me the logit-estimates, which can be transformed into probabilities using plogis(logit)
. So using something like plogis(predict(glm_fit, type = "terms"))
would give me the adjusted probabilities of success for each predictor.
But what would be the equivalent for Poisson regression? How can I "predict" the adjusted incidents rates for each predictor?
Given this example:
set.seed(123)
dat <- data.frame(y = rpois(100, 1.5),
x1 = round(runif(n = 100, 30, 70)),
x2 = rbinom(100, size = 1, prob = .8),
x3 = round(abs(rnorm(n = 100, 10, 5))))
fit <- glm(y ~ x1 + x2 + x3, family = poisson(), data = dat)
and using predict.glm(fit, type = "terms")
I get:
x1 x2 x3
1 -0.023487964 0.04701003 0.02563723
2 0.052058119 -0.20041119 0.02563723
3 0.003983339 0.04701003 0.01255701
4 -0.119637524 0.04701003 -0.03322376
5 0.010851165 0.04701003 -0.00706332
6 -0.105901873 -0.20041119 -0.00706332
...
attr(,"constant")
[1] 0.3786072
So, how many "incidents" (y-value) would I expect for each value of x1
, holding x2
and x3
constant (what predict
does, afaik)?
Upvotes: 3
Views: 848
Reputation: 7832
Ok, I guess I now found what I was looking for: the inverse link-function. So, family(fit)$linkinv(eta = ...)
gives me the correct predicted values / effects for different model families and link functions.
For instance, for binomial regression with logit-link, family(fit)$linkinv(eta = x)
is equivalent to plogis(x)
.
Upvotes: 0