I am trying to fit a Negative Binomial regression in R with the following code:
glm.nb(crash ~ offset(log(VMT)), data=df)
But getting this error:
Error in glm.fitter(x = X, y = Y, w = w, start = start, etastart = etastart, : NA/NaN/Inf in 'y'
How to fix this error? I intalled and loaded all the required packages (i.e. MASS
, foreign
, compactr
).
Data:
crash <- c(46, 10, 9, 1, 0, 4, 14, 18, 7, 23, 16, 1, 2, 5, 3, 16)
VMT <- c(4800, 2769.5, 3990, 2808, 880, 2291, 3220, 3120, 2040, 2115.75, 2635, 1092, 1456, 2433.9, 921.85, 1256.51)
df <- data.frame(crash, VMT)