Description Usage Arguments Value Examples
View source: R/optimize_lambda.R
This function help to choose optimal lambda parameter from a given set by conducting cross-validation to the models with different lambdas and return the lambda that gives the smallest mean squared error. This function was based on the function ridge_regression.
1 | optimize_lambda(formula, data, lambda.set, folds = 10, ...)
|
formula |
a symbolic description of the model to be fitted. This should be a formula class argument. |
data |
Specification of a dataframe that contains the variables in the model. |
lambda.set |
a set of lambdas to be checked. This should be a vector of values or a sequence of numbers. |
folds |
Number of folds used in the k-fold cross-validation |
... |
other inputs that need to be passed to the function ridge_regression. |
a optimal value from the specified set of lambda which returns the smallest MSE in the cross-validation check, the vector of MSE over all lambdas, and the minimum of the MSE.
1 2 | data(iris)
optimize_lambda(Sepal.Length ~ ., iris, seq(0,2,0.01))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.