glmnet: How do I know which factor level of my response is coded as 1 in logistic regression
<p>I have a logistic regression model that I made using the <code>glmnet</code> package. My response variable was coded as a factor, the levels of which I will refer to as "a" and "b".</p>

<p>The mathematics of logistic regression label one of the two classes as "0" and the other as "1". The feature coefficients of a logistic regression model are either positive, negative, or zero. If a feature "f"'s coefficient is positive, then increasing the value of "f" for a test observation x increases the probability that the model classifies x as being of class "1".</p>

<p>My question is: Given a <code>glmnet</code> model, how do you know how <code>glmnet</code> mapped your data's factor labels {"a", "b"} to the underlying mathematics' factor labels {"0", "1"}? Because you need to know that to interpret the model's coefficients properly.</p>

<p>You can figure this out manually by experimenting with the output of the <code>predict</code> function when applied to toy observations. But it would be nice to how <code>glmnet</code> implicitly handles that mapping to speed up the interpretation process.</p>

<p>Thank you!</p>