coolish_con | R Documentation |
Linearly shrinks coordinate of least squared estimates with constrains to solve multivariate linear prediction problems.
coolish_con(x_tr, y_tr, x_te)
x_tr |
training predictor matrix (n_tr x p) |
y_tr |
training response matrix (n_tr x q) |
x_te |
testing predictor matrix (n_te x p) |
y |
estimated response matrix of testing set (n_te x q) |
n_tr = 100 n_te = 10 p = 30 q = 1000 set.seed(1) B = matrix(rnorm(p*q), p, q) B[6:p, ] = 0 x_tr = matrix(rnorm(n_tr*p), n_tr, p) x_te = matrix(rnorm(n_te*p), n_te, p) y_tr = x_tr %*% B + matrix(rnorm(n_tr*q), n_tr, q) y_te = x_te %*% B + matrix(rnorm(n_te*q), n_te, q) y_coolish = coolish_con(x_tr, y_tr, x_te) fit_ols = lm(y_tr~x_tr) y_ols = cbind(1, x_te) %*% fit_ols$coefficients mean((y_te-y_coolish)^2) mean((y_te-y_ols)^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.