# average marginal effects and elasticities for negative binomial models in R

I calculated average marginal effects for negative binomial models by using the following code.

``````library(margins)

summary(m3 <- glm.nb(V7 ~ V8 + V3 + V10 + V12 + V2 + V5, data = data)) cplot(m3, what = "effect")
``````

But I got the following error: What do I have to do fix this? What is the code to calculate elasticities for random parameter negative binomial models?

`````` > summary(m3 <- glm.nb(V7 ~ V8 + V3 + V10 + V12 + V2 + V5, data = data))

Call:
glm.nb(formula = V7 ~ V8 + V3 + V10 + V12 + V2 + V5, data = data,
init.theta = 0.4868761319, link = log)

Deviance Residuals:
Min       1Q   Median       3Q      Max
-1.3170  -1.0447  -0.7771   0.1641   2.2438

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -8.979e-01  7.002e-01  -1.282 0.199738
V8          -1.444e-06  4.385e-06  -0.329 0.741903
V3           4.422e-02  1.141e-02   3.874 0.000107 ***
V10          1.933e-05  3.184e-03   0.006 0.995156
V12         -2.394e-03  6.119e-03  -0.391 0.695662
V2           8.191e-03  1.841e-01   0.045 0.964502
V5           5.945e-03  5.945e-03   1.000 0.317260
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Negative Binomial(0.4869) family taken to be 1)

Null deviance: 269.15  on 285  degrees of freedom
Residual deviance: 232.13  on 279  degrees of freedom
AIC: 726.87

Number of Fisher Scoring iterations: 1

Theta:  0.4869
Std. Err.:  0.0901

2 x log-likelihood:  -710.8690

> cplot(m3, what = "effect")
Error in eval(model[["call"]][["data"]], env) :
promise already under evaluation: recursive default argument reference or earlier problems?
``````

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.