Skip to contents

Given previous matrices and a new observation, updates the matrices for ridge regression.

Usage

ridge_update(R_A, b, xs, t, yobs, alpha)

Arguments

R_A

Matrix. Current matrix R_A for an arm. Must not contain NA values.

b

Numeric vector. Current vector b for an arm.

xs

Matrix. Covariates of shape [A, p], where A is the number of observations and p is the number of features. Must not contain NA values.

t

Integer. Current time or instance.

yobs

Numeric vector. Observed outcomes, length A. Must not contain NA values.

alpha

Numeric. Ridge regression regularization parameter. Default is 1.

Value

A list containing updated matrices R_A, R_Ainv, b, and theta.

Examples

set.seed(123)
p <- 3
K <- 5
init <- ridge_init(p, K)
R_A <- init$R_A[[1]]
b <- init$b[1, ]
xs <- matrix(runif(10 * p), nrow = 10, ncol = p)
yobs <- runif(10)
t <- 1
alpha <- 1
updated <- ridge_update(R_A, b, xs, t, yobs[t], alpha)