title: Predictions of ridge regression in R
body: <p>I've been really stuck on this, hope anyone can help me! I have a dataset with 54 columns and I want to make predictions on a test set with ridge regression. </p>
  
  <pre><code>nn &lt;-nrow(longley)
  index &lt;- 1:nrow(longley)
  testindex &lt;- sample(index, trunc(length(index)/3))
  testset &lt;- longley[testindex,]
  trainset &lt;-longley[-testindex,]
  trainset1 &lt;- trainset[,-7]
  
  # Fit the ridge regression model:
  
  mod &lt;- lm.ridge(y ~., data = trainset, lambda = 0.661)
  
  # Predict and evaluate it by using MAE function:
  
  mae &lt;- function(model) {
    y = trainset$Employed  
    y.pred &lt;- predict(model, trainset)
    return(mean(abs(y-y.pred)))
  }
  </code></pre>
  
  <p>When I do this I get the following error message:</p>
  
  <pre><code>Error in UseMethod("predict") : 
    no applicable method for 'predict' applied to an object of class "ridgelm"
  </code></pre>
  
  <p>What could be another way to make predictions with ridge regression that works (also with evaluation metrics such as rsquared and MAE)? </p>