31

I am using knitr in R to produce a document of model outputs. I have suppressed messages and warnings in my code chunk. But I still get the convergence messages. I have looked for settings in the net package and in the multinom function. Does anybody know how to suppress them? I have looked on SO and on the internet. Someone asked a question in 2006 but I can't get the answer returned (and I don't know if it relevant today).

I am running many models in a loop, so it gets verbose very quickly. This also means that I can't easily put the model runs in a different chunk from the output because I am printing tables in each loop. An example of the output I am trying to suppress is below:

# weights: 10 (4 variable) initial value 2454.392816 iter 10 value 2175.558042 iter 10 value 2175.558039 final value 2175.558039 converged

Mark Danese
  • 2,331
  • 1
  • 20
  • 25

1 Answers1

71

I finally found a function argument called "trace" in the nnet function. Its default is TRUE, and when set to "FALSE" the messages stop. I am guessing that nnet is called by multinom. Thank goodness for the ... in R so I could pass a function argument through.

Hopefully this will help someone else. I didn't mean to answer my own question (but I hope that is ok).

Mark Danese
  • 2,331
  • 1
  • 20
  • 25
  • apparently I need to wait 2 days until I can accept my own answer. – Mark Danese Apr 09 '15 at 02:48
  • Actually I found trace before seeing your answer but it says "switch for tracing optimization. Default TRUE." Which I thought was something else. R, its packages and documentations are so painful. https://cran.r-project.org/web/packages/nnet/nnet.pdf – Scientist1642 Mar 22 '16 at 00:45