How can I fit a GLM using R's glm() evaluated at specific values (e.g. median)?

348 views Asked by At

I would like to fit a generalized linear model in R, using glm(). More precisely, it's a nb.glm(). Apparently, coefficients fitted in R packages that deal with generalized linear models are all evaluated at mean values of the other variables. Is there a way to evaluate coefficients holding the values of other variables constant at e.g. median or zero?

For example, the example from UCLA's ATS site on NegBin regression:

require(foreign)
require(ggplot2)
require(MASS)
dat <- read.dta("http://www.ats.ucla.edu/stat/stata/dae/nb_data.dta")
dat <- within(dat, {
    prog <- factor(prog, levels = 1:3, labels = c("General", "Academic", "Vocational"))
    id <- factor(id)
})
summary(m1 <- glm.nb(daysabs ~ math + prog, data = dat))

The resulting coefficients are evaluated at the mean value of daysabs, which is 5.96. It find it more intuitive to evaluate the coefficients at median values.

0

There are 0 answers