3

I tried to do multinomial logit regression in R. I used the following command:

fit <- glmnet(xdata, newdata2$state, family="multinomial" )

but I got this error:

Error: from glmnet Fortran code (error code 8001); Null probability for class 1 < 1.0e-5

I don't know how should I fix this error and I will be thankful for any help. Also please let me know if there is any easier way to perform multinomial logit regression (and not bionomial) in R.

EDIT:

table(newdata2$state)
Bad   D    F    H IND   PR RRT RRT1 RRT2 RRT3
0   722 9691 1273 187 2058 937    0    0    0 
smci
  • 32,567
  • 20
  • 113
  • 146
user54626
  • 55
  • 7
  • 1
    what does `table(newdata2$state)` give you? – adibender Mar 11 '14 at 00:12
  • Bad D F H IND PR RRT RRT1 RRT2 RRT3 0 722 9691 1273 187 2058 937 0 0 0 – user54626 Mar 11 '14 at 01:34
  • This is what I get. Bad, D, F,..., RRT3 are the states of a patient on tommorrow and I am trying to create transition probabilities of moving to each of these states using this multinomial logit model. – user54626 Mar 11 '14 at 01:40
  • 4
    well, it looks like algorithm breaks down because couple of your categories have cell count `0`. Try to exclude these and rerun the analysis... – adibender Mar 11 '14 at 08:32
  • If x can be 0, then instead of estimating x, try estimating (x+1). glmnet works fine. Instead of raw glmnet, try using cv.glmnet(nfolds =3 or higher) to get a crossvalidated estimator. It also has the advantage of being pretty robust to class imbalances. – smci Jul 11 '15 at 19:43
  • If RRT1/2/3 can never occur, then exclude them from training. Or if they're just very rare then consider using the [Bonferroni correction](https://en.wikipedia.org/wiki/Bonferroni_correction) for rare events. – smci Jul 11 '15 at 19:48

0 Answers0