17.2 Explore Your Own Adventure Path

{
# 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

Your email address will not be published. Required fields are marked *