{
# Add a column of 1s for the intercept
X <- cbind(1, X)
# Calculate the linear predictor
mu <- X %*% par
# Calculate the sum squared error
error <- sum((y – mu)^2)
# Add the penalty term
value <- error + lambda * sum(par^2)
return(value)
}

Leave a Reply