Description Usage Arguments Value Examples
This function uses the gradient descent algorithm (matrix form) to solve OLS using 10-fold cross validation (to calculate out-of-sample accuracy).
1 | ols_gd_hw2b(form, d, b_0, learn_rate, max_iter, contrasts = NULL)
|
form |
linear model formula |
d |
data frame |
b_0 |
parameters of model: column vector of initialized coefficients |
learn_rate |
the initialized learning rate (aka step size) |
max_iter |
the maximum number of iterations for this algorithm |
contrasts |
optional list of constants for factor variables aka contrast |
the estimated coefficients, as well as the penalty (loss)
1 2 3 4 5 | set.seed(2020)
x <- -30:30
df <- data.frame(y = 6 + 7*x + rnorm(length(x)), x = x)
bis557::ols_gd_hw2b(form = y ~ ., d = df, b_0 = rep(1e-16, 2),
learn_rate = 0.18, max_iter = 1e5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.