title: How to calculate R Squared value for Lasso regression using glmnet in R
body: <p>I am performing lasso regression in R using glmnet package: </p>
  
  <pre><code>fit.lasso &lt;- glmnet(x,y)
  plot(fit.lasso,xvar="lambda",label=TRUE)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JMiq6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JMiq6.png" alt="fit.lasso plot"></a></p>
  
  <p>Then using cross-validation: </p>
  
  <pre><code>cv.lasso=cv.glmnet(x,y)
  plot(cv.lasso)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Lnr5X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lnr5X.png" alt="lambda VS MSE"></a></p>
  
  <p><a href="http://myweb.uiowa.edu/pbreheny/7600/s16/notes/2-22.pdf" rel="nofollow noreferrer">One tutorial</a> (last slide) suggest the following for R^2: </p>
  
  <pre><code>R_Squared =  1 - cv.lasso$cvm/var(y)
  </code></pre>
  
  <p>But it did not work. </p>
  
  <p>I want to understand the model efficiency/performance in fitting the data. As we usually get R^2 and adjusted R^2 when performing lm() function in r. </p>