1

I've recently run a code which is:

glmnet.fit <- with(training.df, glmnet(poly(X, degree = 10), Y))
lambdas <- glmnet.fit$lambda
performance <- data.frame()
for (lambda in lambdas)
{
  performance <- rbind(performance,
                       data.frame(Lambda = lambda,
                                  RMSE = rmse(test.y,
                                              with(test.df,
                                                   predict(glmnet.fit,
                                                           poly(X, degree = 10),
                                                           s = lambda)))))
}

what does the parameter 's' in this case mean?Could't find it in the help file.

tour
  • 31
  • 3
  • 1
    Please list the non-base R packages that you are using. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Mar 09 '21 at 07:54
  • 1
    This seems like the correct documentation: https://www.rdocumentation.org/packages/glmnet/versions/4.1-1/topics/predict.cv.glmnet – MrFlick Mar 09 '21 at 07:54

1 Answers1

1

To find the documentation of the predict function for different objects, you can usually use ?predict.objectName. So for instance, to find the documentation for the predict function for lm objects, you'd use ?predict.lm.

In this case, you have a glmnet object, and you can use ?predict.glmnet to find the relevant documentation, which describes s as follows:

  • s - Value(s) of the penalty parameter lambda at which predictions are required. Default is the entire sequence used to create the model.
MånsT
  • 904
  • 5
  • 19