title: How to set specific contrasts in multinom() in nnet package?
body: <p>I have a 3-class problem that needs classification. I want to use the multinomial logistic regression in <code>nnet</code> package.
  The Class outcome has 3 factors, P, Q, R. I want to treat Q as the base factor. </p>
  
  <p>So I tried to write it the contrasts like this:  </p>
  
  <pre><code>P &lt;- c(1,0,0)
  R &lt;- c(0,0,1)
  contrasts(trainingLR$Class) &lt;- cbind(P,R)
  </code></pre>
  
  <p>checked it:  </p>
  
  <pre><code>&gt; contrasts(trainingLR$Class)
    P R
  P 1 0
  Q 0 0
  R 0 1 
  </code></pre>
  
  <p>Now <code>multinom()</code>:</p>
  
  <pre><code>library(nnet)
  multinom(Class ~., data=trainingLR)
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>&gt; multinom(Class ~., data=trainingLR)
  # weights:  39 (24 variable)
  initial  value 180.172415 
  iter  10 value 34.990665
  iter  20 value 11.765136
  iter  30 value 0.162491
  iter  40 value 0.000192
  iter  40 value 0.000096
  iter  40 value 0.000096
  final  value 0.000096 
  converged
  Call:
  multinom(formula = Class ~ ., data = trainingLR)
  
  Coefficients:
    (Intercept)        IL8     IL17A      IL23A     IL23R
  Q   -116.2881 -16.562423 -34.80174   3.370051  6.422109
  R    203.2414   6.918666 -34.40271 -10.233787 31.446915
         EBI3     IL6ST     IL12A   IL12RB2     IL12B
  Q -8.316808  12.75168 -7.880954  5.686425 -9.665776
  R  5.135609 -20.48971 -2.093231 37.423452 14.669226
      IL12RB1    IL27RA
  Q -6.921755 -1.307048
  R 15.552842 -7.063026
  
  Residual Deviance: 0.0001922658 
  AIC: 48.00019 
  </code></pre>
  
  <p><strong>Question:</strong><br>
  So as you see, since P class didn't appear in the output, it means that it was treated as base being the first one in alphabetical order as expected when dealing with factor variables in R, and Q class was <em>not</em> treated as base level in this case, how to make it base to the other two levels? </p>