lmn_suff | R Documentation |
Calculate the sufficient statistics of an LMN model.
lmn_suff(Y, X, V, Vtype, npred = 0)
Y |
An |
X |
An
|
V, Vtype |
The between-observation variance specification. Currently the following options are supported:
For |
npred |
A nonnegative integer. If positive, calculates sufficient statistics to make predictions for new responses. See Details. |
The multi-response normal linear regression model is defined as
Y ~ Matrix-Normal(X B, V, Σ),
where Y_(n x q) is the response matrix, X_(n x p) is the covariate matrix, B_(p x q) is the coefficient matrix, V_(n x n) and Σ_(q x q) are the between-row and between-column variance matrices, and the Matrix-Normal distribution is defined by the multivariate normal distribution vec(Y) ~ N( vec(X B), Σ %x% V ), where vec(Y) is a vector of length nq stacking the columns of of Y, and Σ %x% V is the Kronecker product.
The function lmn_suff()
returns everything needed to efficiently calculate the likelihood function
L(B, Σ | Y, X, V) = p(Y | X, V, B, Σ).
When npred > 0
, define the variables Y_star = rbind(Y, y)
, X_star = rbind(X, x)
, and V_star = rbind(cbind(V, w), cbind(t(w), v))
. Then lmn_suff()
calculates summary statistics required to estimate the conditional distribution
p(y | Y, X_star, V_star, B, Σ).
The inputs to lmn_suff()
in this case are Y = Y
, X = X_star
, and V = V_star
.
An S3 object of type lmn_suff
, consisting of a list with elements:
Bhat
The p x q matrix B_hat = (X'V^{-1}X)^{-1}X'V^{-1}Y.
T
The p x p matrix T = X'V^{-1}X.
S
The q x q matrix S = (Y-X B_hat)'V^{-1}(Y-X B_hat).
ldV
The scalar log-determinant of V
.
n
, p
, q
The problem dimensions, namely n = nrow(Y)
, p = nrow(Beta)
(or p = 0
if X = 0
), and q = ncol(Y)
.
In addition, when npred > 0
and with x, w, and v defined in Details:
Ap
The npred x q
matrix A_p = w'V^{-1}Y.
Xp
The npred x p
matrix X_p = x - w'V^{-1}X.
Vp
The scalar V_p = v - w'V^{-1}w.
# Data n <- 50 q <- 3 Y <- matrix(rnorm(n*q),n,q) # No intercept, diagonal V input X <- 0 V <- exp(-(1:n)/n) lmn_suff(Y, X = X, V = V, Vtype = "diag") # X = (scaled) Intercept, scalar V input (no need to specify Vtype) X <- 2 V <- .5 lmn_suff(Y, X = X, V = V) # X = dense matrix, Toeplitz variance matrix p <- 2 X <- matrix(rnorm(n*p), n, p) Tz <- SuperGauss::Toeplitz$new(acf = 0.5*exp(-seq(1:n)/n)) lmn_suff(Y, X = X, V = Tz, Vtype = "acf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.