R: NA / NaN / Inf in error X

I try to perform negative binomial regression using R. When I execute the following command:

DV2.25112013.nb <- glm.nb(DV2.25112013~ Bcorp.Geographic.Proximity + Dirty.Industry + Clean.Industry + Bcorp.Industry.Density + State + Dirty.Region + Clean.Region + Bcorp.Geographic.Density + Founded.As.Bcorp + Centrality + Bcorp.Industry.Density.Squared + Bcorp.Geographic.Density.Squared + Regional.Institutionalization + Sales + Any.Best.In.Class + Dirty.Region.Heterogeneity + Clean.Region.Heterogeneity + Ind.Dirty.Heterogeneity+Ind.Clean.Heterogeneity + Industry, data = analysis25112013DF6) 

R gives the following error:

 Error in glm.fitter(x = X, y = Y, w = w, etastart = eta, offset = offset, : NA/NaN/Inf in 'x' In addition: Warning message: step size truncated due to divergence 

I do not understand this error, since my data matrix does not contain NA / NaN / Inf values ​​... how can I fix this?

Thank you,

+6
source share
2 answers

I think the most likely cause of this error is negative values ​​or zeros in the data, since the default link in glm.nb is a "log". It would be easy enough to test by changing link="identity" . I also think you need to try smaller models .... maybe a quarter of these variables start. It also allows you to add related variables in the form of bunches, since they look from names that you might have serious potential for collinearity with categorical variables.

We really need a description of the data. I wondered about Dirty.Industry + Clean.Industry . This is a kind of dichotomy that is better handled by a factor variable that has these levels. This prevents collinearity if Clean = not-Dirty. Perhaps similar to your heterogeneity variables. (I'm not sure @BenBolker's comment is correct. I think it is very likely that you will first need statistical consultation before address encoding problems.)

 require(MASS) data(quine) # following example in ?glm.nb page > quine$Days[1] <- -2 > quine.nb1 <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine, link = "identity") Error in eval(expr, envir, enclos) : negative values not allowed for the 'Poisson' family > quine$Days[1] <- 0 > quine.nb1 <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine, link = "identity") Error: no valid set of coefficients has been found: please supply starting values In addition: Warning message: In log(y/mu) : NaNs produced 
+1
source

I solved this problem by putting the control argument in model assumptions with maxiter = 10 or lower. default is 50 iterations. perhaps this works for you with even more iterations. just try

+1
source

All Articles