2

I'm using the multinom() function in the nnet package. My data has a little over a million rows and 4 independent variables. The multinom() function itself creates a model within ~15 minutes, and I can view coefficients.

I need to access them as an object though (with $coefficients) but I can't unless I save a summary() of it. When I try summarizing my model, it's run for over 30 minutes with no end in sight.

Is there any reason the summary() function takes so long, for what seems to be a basic reporting tool? How can I speed it up? Is there another way to access the coefficients?

lmo
  • 37,904
  • 9
  • 56
  • 69
Nicholas Hassan
  • 949
  • 2
  • 10
  • 27
  • Have you tried using the `broom` package to make it easier to access regression components? https://github.com/hadley/broom – Andrew Brēza Aug 01 '17 at 14:17
  • Take a look at `str(myMulitnomResult)` (or whatever name you gave it) to see what elements are stored in the regression results directly. – lmo Aug 01 '17 at 14:19
  • 1
    @AndrewBrēza Thank you I'll give that a shot – Nicholas Hassan Aug 01 '17 at 14:30
  • @Imo Thanks! I'm just afraid to stop the summary() function now to check... who knows how close I might be :/ – Nicholas Hassan Aug 01 '17 at 14:31
  • I think that's because summary shows the standard errors of your coefficients, and requires calculating the Hessian & its inverse (the variance covariance matrix) and this can be very slow... – Tom Wenseleers Sep 21 '22 at 23:43

1 Answers1

4

If you just want the coefficients, use only the coef() method, which do much less computations.

F. Privé
  • 11,423
  • 2
  • 27
  • 78
  • That works great. The output of `summary(test)$coefficients` is the same as `coef(test)` but much quicker. – Tapper Jan 12 '21 at 13:42