# Cross-validation
tune <- trainSLOPE(
bodyfat$x,
bodyfat$y,
q = c(0.1, 0.2),
measure = "mse"
)
# Refit with optimal parameters
fit <- refit(tune, bodyfat$x, bodyfat$y)
# Use the fitted model
coef(fit)
predict(fit, bodyfat$x)
Run the code above in your browser using DataLab