I am running a negative binomial model without creating a glm object in R. I found an answer at StackExchange on how to get standard errors "by-hand" here, but it shows only how to get values on a linear scale, not in the scale of the response, just as by default for type argument in predict(). To go from a linear scale to the scale of the fitted values for a negative binomial is just exp(fit), but how to get standard errors?


1 Answer 1


To get the standard errors, you could either approximate them with the delta method, or just use simulation! You can probably use the simulate() generic in R.

For help on how to use the delta method, have a look at the answer to Calculating the Variance using Delta Method

Following, an example on how to get the standard errors from the model object by simulation. I give an Poisson example, where we know the standard error from the mean, so as to be able to check on the simulations. Code:

n  <-  100
N  <-  1000 # number of replications
y  <-  rpois(n, lambda=exp(5+x))
mod  <-  glm(y~x, family=poisson())
sims  <-  simulate(mod, nsim=N)  # this is sims from the estimated predictive distribution
preds  <-  matrix(0,n,N)
for (i in seq(along=sims)) {
    preds[,i]  <-  sims[[i]]
means  <-  apply(preds,1,mean)
vars   <-  apply(preds,1,var)

the plot showing the expected linear relation.

  • 1
    $\begingroup$ thanks for your response, I agree using bootstrap or other randomization procedure as a valid alternative. To be honest your R code did not help me much, but generally this alternative looks like an easy solution I am going to try. $\endgroup$ Nov 4, 2016 at 18:45
  • $\begingroup$ I will post an update with some better suggestions! $\endgroup$ Nov 4, 2016 at 18:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.