I estimated a negative binomial regression model in R that counts the number of cyberattacks a country initiates per year. My unit of observation is country-year.

Since cyberattacks are a very rare occurrence in my dataset, about 80% of all observations equal 0.

Now I want to calculate and present the marginal effects for my regression. Unfortunately, the effects-package always returns identical values (2.220446e-16).

This is the code I am using:

ModelA <- glm.nb(attacks ~ cinc + maj.fac + I(log(gdp_pc)) + years_since_dispute,
                   data = data)

# Now I estimate the maginal effects for my first exlanatory variable, "cinc":
effect(term = "cinc", mod = ModelA, typical = median,
       given.values = c(maj.fac = 1))  # maj.fac is a dummy, so I hold it constant

The outcome is the same, regardless for which explanatory variable and regardless at which level I hold my dummy variable constant:

 cinc effect
     0.00016        0.055         0.11         0.16         0.22 
2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 

Does anyone have an idea what I may be doing wrong?

I assume that the problem lies with the fact that my dependent variable measures a very rare occurrence.

Is there something I can do to get marginal effects that are not totally identical or does anyone have a better idea how I could estimate the marginal effects?

I would really appreciate your help,


  • 1
    $\begingroup$ The problem may be that you have typical = median; when you try typical = mean, do you get the same values? The median may be invariant to small changes in your predictors, but the mean should change. $\endgroup$ – Noah Jul 10 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.