title: How to predict with multinom() in R
body: <p>I'm trying to calculate predicted probabilities using specific values, but R shows the following error:</p>
  
  <pre><code>Error in model.frame.default(Terms, newdata, na.action = na.omit, xlev = object$xlevels) : 
    variable lengths differ (found for 'x')
  In addition: Warning message:
  'newdata' had 1 rows but variable(s) found have 513 rows
  </code></pre>
  
  <p>This is what I was trying to do: x1 is a factor with 12 levels, and x2 is also a factor with 3 levels.</p>
  
  <pre><code>res4 &lt;- multinom(y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 - 1, data=dta, Hess=T)
  
  nd &lt;- data.frame(x11=0.10331384, x12=0.07992203, x13=0.06237817, x14=0.03313840, x15=0.12280702, x16=0.07407407, x17=0.07407407, x18=0.10331384, x19=0.08966862, x110=0.07017544, x111=0.15009747, x112=0.03703704, x22=1, x23=0, x3=1, x4=1, x5=mean(x5), x6=mean(x6, na.rm=T), x7=mean(x7), x8=mean(x8), x9=mean(x9))
  
  predict(res4, type="probs", newdata=nd)
  </code></pre>
  
  <p>Any help?</p>