17.3 Discover Essential Resources Beyond the Basics

{
# Add a column of 1s for the intercept
X = cbind(1, X)

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