# lrt_null_dist_dim_same: Draw from null distribution of likelihood ratio test... In tensr: Covariance Inference and Decompositions for Tensor Datasets

## Description

When testing for the covariance structure of modes, this function may be used to draw a sample from the null distribution of the likelihood ratio test stistics, whose distribution doesn't depend on any unknown parameters under the null.

## Usage

 1 2 3 lrt_null_dist_dim_same(p, null_ident = NULL, alt_ident = NULL, null_diag = NULL, alt_diag = NULL, reference_dist = "normal", t_df = NULL, itermax = 100, holq_itermax = 100, holq_tol = 10^-9) 

## Arguments

 p A vector of integers. The dimensions of the array. null_ident A vector of integers. The modes that under the null have identity covariance. alt_ident A vector of integers. The modes that under the alternative have the identity covariance. null_diag A vector of integers. The modes that under the null have diagonal covariance. alt_diag A vector of integers. The modes that under the alternative have diagonal covariance. reference_dist Two options are supported, 'normal' and 't'. If 't' is specified, you have to specify t_df. t_df A numeric. If reference_dist is 't', then this is the degrees of freedom of the t_distribution that the array is distributed under. itermax An integer. The number of draws from the null distribution of the likelihood ratio test statistic that is to be performed. holq_itermax An integer. The maximum number of block coordinate ascent iterations to perform when calculating the MLE at each step. holq_tol A numeric. The stopping criterion when calculating the MLE.

## Details

Let vec(X) be N(0,Σ). Given two nested hypotheses,

H_1: Σ = Ψ_K\otimes\cdots\otimesΨ_1

versus

H_0: Σ = Ω_K\otimes\cdots\otimesΩ_1,

this function will draw from the null distribution of the likelihood ratio test statistic. The possible options are that Ψ_i or Ω_i are the identity matrix, a diagonal matrix, or any positive definite matrix. By default, it's assumed that these matrices are any positive definite matrix.

Unfortunately, this fuction does not support testing for the hypothesis of modeling the covariance between two modes with a single covariance matrix. I might code this up in later versions.

## Value

A vector of draws from the null distribution of the likelihood ratio test statistic.

David Gerard.

## References

Gerard, D., & Hoff, P. (2016). A higher-order LQ decomposition for separable covariance models. Linear Algebra and its Applications, 505, 57-84. https://doi.org/10.1016/j.laa.2016.04.033 http://arxiv.org/pdf/1410.1094v1.pdf

lrt_stat for calculating the likelihood ratio test statistic.
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 #Test for all identity versus all unconstrained. p = c(4,4,4) null1 <- lrt_null_dist_dim_same(p,null_ident = 1:3) #Generate Null Data X <- array(stats::rnorm(prod(p)), dim = p) sig_null <- holq(X, mode_rep = 1:3)$sig sig_alt <- holq(X)$sig lrt_x <- lrt_stat(sig_null, sig_alt, p = p) p_value <- mean(null1 > lrt_x) hist(null1,main = 'Null Distribution of LRT', xlab = 'LRT Statistic') abline(v = lrt_x, lty = 2, col = 2, lwd = 2) legend('topleft', 'Observed LRT Statistic', lty = 2, col = 2, lwd = 2) mtext(side = 1, paste('P-value = ', round(p_value, digits = 2), sep = ''), line = 2) #------------------------------------------------------------------------- #Test for all identity versus all mode 1 identity, # mode 2 diagonal, mode 3 unconstrained. p = c(4,4,4) null2 <- lrt_null_dist_dim_same(p,null_ident = 1:3, alt_ident = 1, alt_diag = 2) #Generate Null Data X <- array(stats::rnorm(prod(p)), dim = p) sig_null <- holq(X, mode_rep = 1:3)$sig sig_alt <- holq(X, mode_rep = 1, mode_diag = 2)$sig lrt_x <- lrt_stat(sig_null, sig_alt, p = p) p_value <- mean(null2 > lrt_x) hist(null2,main = 'Null Distribution of LRT', xlab = 'LRT Statistic') abline(v = lrt_x, lty = 2, col = 2, lwd = 2) legend('topleft', 'Observed LRT Statistic', lty = 2, col = 2, lwd = 2) mtext(side = 1, paste('P-value = ', round(p_value, digits = 2), sep = ''), line = 2)