title: Behaviour of dfmax in glmnet
body: <p>(NB: This is a slightly modified version of a post I'd made on a different forum. I received no responses there, hence the post here. If this is not allowed, please let me know, will take down the question).</p>
  
  <p>I am new to <i>glmnet</i>, so I do not yet understand fully what the various 
  parameters do. I am trying to build a multinomial classifier which restricts 
  the number of features used in the model. From reading the docs and some 
  answers on this forum, I understand <code>dfmax</code> is the way to do it. I 
  played around with it a bit; I have a couple of questions and would appreciate some help: </p>
  
  <h3>Setup</h3> 
  
  <p>For a particular dataset, I want to restrict the number of features to 3; 
  the original data has 126 features. Here's what I run: </p>
  
  <pre><code>fit&lt;-glmnet(data.matrix(X), data.matrix(y), family='multinomial', dfmax=3) 
  d&lt;-data.frame(tidy(fit)) 
  </code></pre>
  
  <p>This is the value of <code>d</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/jluFa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jluFa.png" alt="enter image description here"></a></p>
  
  <p>My questions about the output: </p>
  
  <ol>
  <li>I see multiple values of <code>lambda</code> in there; it looks like
  glmnet tries to fit <code>lambda</code>s that gets the number of terms close to
  <code>dfmax=3</code>. So its less like the LARs algorithm (where we
  move stagewise by adding variables and can stop at an exact number of variables) and more about getting the
  right <code>lambda</code>s for regularization that lead to the intended <code>dfmax</code>. Is
  this right?  </li>
  <li>I'm guessing <code>alpha</code> plays a role in how close we can get
  to <code>dfmax</code>. At <code>alpha=1</code>, where we're doing lasso, and so its easier to
  get close to <code>dfmax</code>, compared to when <code>alpha=0</code> and we're doing ridge.
  Is this understanding correct?  </li>
  <li>A "neighborhood" of <code>dfmax</code> is the
  best we can do it'd seem. Or am I missing a parameter that gets me
  to the model with the exact <code>dfmax</code> (FYI: <code>alpha=1</code> doesn't seem to get
  me to the precise number of non zero terms either, at least on this
  dataset).</li>
  <li>In the first solution - <code>step=1</code>, there are no variables used. Does this mean the relative odds equal a constant?</li>
  <li>What does <code>pmax</code> do?</li>
  </ol>
  
  <p>Thanks in advance!</p>