Here is my code, but I have this error ..
model <- glmrob(x ~ as.factor(i) + as.factor(j),
family = poisson(link = "log"), data = myData,method="MT")
error message:
Error in optim(start, sumaConPesos, method = "L-BFGS-B", x = x, y = y, : non-finite value supplied by optim
I strongly suspect this is an example of Andrew Gelman's folk theorem of statistical computing:
If I replicate your example 100 times I get errors every time, but different errors different times:
gives 80 instances of your "non-finite value supplied by optim" error and 20 cases of "Error in solve.default(de/n): Lapack routine dgesv: system is exactly singular: U[x,x] = 0" for a variety of values of x.
I've dug down within the function, using
debug
on various levels. The problem seems to be that the initialization procedure (glmrobMT -> beta0IniCP -> betaExacto
) randomly samples (without replacement) a number of rows from the data equal to the number of columns of the model matrix (19) and tries to fit a poisson GLM to it. Because of the structure of your data, these subsamples are almost always multicollinear, leading toNA
values in the coefficients, which screws things up down the line.I don't know how to fix this, but I would ask the following general modeling questions: