coolish_con: Constrained Coordinate Linear Shrinkage method (COOLISH)

View source: R/coolish.R

coolish_conR Documentation

Constrained Coordinate Linear Shrinkage method (COOLISH)

Description

Linearly shrinks coordinate of least squared estimates with constrains to solve multivariate linear prediction problems.

Usage

coolish_con(x_tr, y_tr, x_te)

Arguments

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)

Value

y

estimated response matrix of testing set (n_te x q)

Examples

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)

sdzhao/cole documentation built on May 2, 2022, 9:42 a.m.