Density and random generation for the matrix variate t distribution.

rmatrixt(
  n,
  df,
  mean,
  L = diag(dim(as.matrix(mean))[1]),
  R = diag(dim(as.matrix(mean))[2]),
  U = L %*% t(L),
  V = t(R) %*% R,
  list = FALSE,
  array = NULL,
  force = FALSE
)

dmatrixt(
  x,
  df,
  mean = matrix(0, p, n),
  L = diag(p),
  R = diag(n),
  U = L %*% t(L),
  V = t(R) %*% R,
  log = FALSE
)

Arguments

n

number of observations for generation

df

degrees of freedom (\(>0\), may be non-integer), df = 0, Inf is allowed and will return a normal distribution.

mean

\(p \times q\) This is really a 'shift' rather than a mean, though the expected value will be equal to this if \(df > 2\)

L

\(p \times p\) matrix specifying relations among the rows. By default, an identity matrix.

R

\(q \times q\) matrix specifying relations among the columns. By default, an identity matrix.

U

\(LL^T\) - \(p \times p\) positive definite matrix for rows, computed from \(L\) if not specified.

V

\(R^T R\) - \(q \times q\) positive definite matrix for columns, computed from \(R\) if not specified.

list

Defaults to FALSE . If this is TRUE , then the output will be a list of matrices.

array

If \(n = 1\) and this is not specified and list is FALSE , the function will return a matrix containing the one observation. If \(n > 1\) , should be the opposite of list . If list is TRUE , this will be ignored.

force

In rmatrix: if TRUE, will take the input of R directly - otherwise uses V and uses Cholesky decompositions. Useful for generating degenerate t-distributions. Will also override concerns about potentially singular matrices unless they are not, in fact, invertible.

x

quantile for density

log

logical; in dmatrixt, if TRUE, probabilities p are given as log(p).

Value

rmatrixt returns either a list of \(n\) \(p \times q\) matrices or a \(p \times q \times n\) array.

dmatrixt returns the density at x.

Details

The matrix \(t\)-distribution is parameterized slightly differently from the univariate and multivariate \(t\)-distributions

  • the variance is scaled by a factor of 1/df. In this parameterization, the variance for a \(1 \times 1\) matrix variate \(t\)-distributed random variable with identity variance matrices is \(1/(df-2)\) instead of \(df/(df-2)\). A Central Limit Theorem for the matrix variate \(T\) is then that as df goes to infinity, \(MVT(0, df, I_p, df*I_q)\) converges to \(MVN(0,I_p,I_q)\).

References

Gupta, Arjun K, and Daya K Nagar. 1999. Matrix Variate Distributions. Vol. 104. CRC Press. ISBN:978-1584880462

Dickey, James M. 1967. “Matricvariate Generalizations of the Multivariate t Distribution and the Inverted Multivariate t Distribution.” Ann. Math. Statist. 38 (2): 511–18. doi: 10.1214/aoms/1177698967

See also

Examples

set.seed(20180202)
# random matrix with df = 10 and the given mean and L matrix
rmatrixt(
  n = 1, df = 10, mean = matrix(c(100, 0, -100, 0, 25, -1000), nrow = 2),
  L = matrix(c(2, 1, 0, .1), nrow = 2), list = FALSE
)
#>            [,1]         [,2]      [,3]
#> [1,] 99.7106463 -100.9726544   25.3467
#> [2,] -0.1341239   -0.4413188 -999.8511
# comparing 1-D distribution of t to matrix
summary(rt(n = 100, df = 10))
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -3.25709 -0.98684 -0.13442 -0.09184  0.77896  3.11982 
summary(rmatrixt(n = 100, df = 10, matrix(0)))
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -1.06175 -0.13456  0.03359  0.03465  0.21606  0.85072 
# demonstrating equivalence of 1x1 matrix t to usual t
set.seed(20180204)
x <- rmatrixt(n = 1, mean = matrix(0), df = 1)
dt(x, 1)
#>           [,1]
#> [1,] 0.1574079
dmatrixt(x, df = 1)
#> [1] 0.1574079