title: glmnet 4.0 negative binomial regression: "Error in seq.default(log(lambda_max), log(lambda_max * lambda.min.ratio), : 'from' must be a finite number"
body: <p>I am trying to run a negative binomial regression using the <a href="https://www.rdocumentation.org/packages/glmnet/versions/4.0" rel="nofollow noreferrer">glmnet 4.0 package</a>. I have implemented the regression using code from the section entitled 'Fitting Other GLMs' of this <a href="https://glmnet.stanford.edu/articles/glmnetFamily.html" rel="nofollow noreferrer">webpage</a>. However, I keep getting the following error:</p>
  <pre><code>Error in seq.default(log(lambda_max), log(lambda_max * lambda.min.ratio), : 'from' must be a finite number
  </code></pre>
  <p>I haven’t been able to find examples of other people experiencing this error in the past. I think maybe because it is specific to this new version of the package?</p>
  <p>Below is an example which should reproduce the error. This is not the data I have been using for my analysis and is simply for example purposes.</p>
  <pre><code>library(eventdataR)
  library(glmnet)
  library(MASS)
  
  df &lt;- subset(traffic_fines, activity == &quot;Create Fine&quot; | activity == &quot;Add penalty&quot; )
  df &lt;- df[,c(4,6,7,9,13,14,18)]
  df$resource &lt;- as.numeric(df$resource)
  dfm &lt;- as.matrix(df[,-3])
  
  newfit &lt;- glmnet(dfm, df$amount, family = negative.binomial(theta = 5))
  </code></pre>
  <p>Does anyone know why this error might be occurring and what I can do to stop it?</p>