Reputation: 13
I am looking to obtain parameter estimates for one predictor when constraining another predictors to specific values in a negative binomial glm in order to better explain an interaction effect.
My model is something like this:
model <- glm.nb(outcome ~ IV * moderator + covariate1 + covariate2)
Because the IV:moderator
term is significant, I would like to obtain parameter estimates for IV
at specific values of moderator
(i.e., at +1 and -1 SD). I can obtain slope estimates for IV
at various levels of moderator
using the visreg
package but I don't know how to estimate SEs and test statistics. moderator
is a continuous variable so I can't use the multcomp
package and other packages designed for finding simple slopes (e.g., pequod
and QuantPsyc
) are incompatible with negative binomial regression. Thanks!
Upvotes: 0
Views: 1327
Reputation: 206232
If you want to constrain one of the values in your regression, consider taking that variable out of the model and adding it in as an offset. For example with the sample data.
dd<-data.frame(
x1=runif(50),
x2=runif(50)
)
dd<-transform(dd,
y=5*x1-2*x2+3+rnorm(50)
)
We can run a model with both x1
and x2
as parameters
lm(y ~ x1 + x2,dd)
# Call:
# lm(formula = y ~ x1 + x2, data = dd)
#
# Coefficients:
# (Intercept) x1 x2
# 3.438438 4.135162 -2.154770
Or say that we know that the coefficient of x2
is -2. Then we can not estimate x2
but put that term in as an offset
lm(y ~ x1 + offset(-2*x2), dd)
# Call:
# lm(formula = y ~ x1 + offset(-2 * x2), data = dd)
#
# Coefficients:
# (Intercept) x1
# 3.347531 4.153594
The offset()
option basically just create a covariate who's coefficient is always 1. Even though I've demonstrated with lm
, this same method should work for glm.nb
and many other regression models.
Upvotes: 2