# multiway_takemura: Calculate a truncated multiway Takemura estimator. In tensr: Covariance Inference and Decompositions for Tensor Datasets

## Description

This function will 'average' Bayes rules given random rotations of the data array. This 'averaged' estimator has lower risk than the uniformly minimum risk equivariant estimator under a product group of lower triangular matrices. Truncated multiway Takemura's estimator is not equivariant with respect to this product group of lower triangular matrices, but it is an equivariant randomized estimator with respect to a product group of orthogonal matrices.

## Usage

 ```1 2``` ```multiway_takemura(X, ortho_max = 2, mcmc_itermax = 1000, start_identity = FALSE, print_mcmc = FALSE, mode_rep = NULL) ```

## Arguments

 `X` An array. This is the data array. `ortho_max` An integer. The number of 'averagings' to perform. `mcmc_itermax` An integer. The number of iterations each MCMC should perform using `equi_mcmc`. `start_identity` Should each MCMC start their covariance matrices at the identity (TRUE) or at the sample covariance matrices (FALSE)? `print_mcmc` Should the output of the MCMC be printed to the screen (TRUE) or not (FALSE)? `mode_rep` A vector of integers. Which mode(s) are considered iid observations? Default is none.

## Details

This function will (1) randomly rotate `X` along every mode, then (2) it will calculate the uniformly minimum risk equivariant estimator using `equi_mcmc`, then (3) it will 'average' these estimates.

## Value

`B` A list of the truncated multiway Takemura's estimators for each component covariance matrix. Not their Cholesky square roots.

`b` Truncated multiway Takemura's estimator for the total variation parameter. The 'variance' form, not the 'standard devation' form.

David Gerard.

## References

Gerard, D., & Hoff, P. (2015). Equivariant minimax dominators of the MLE in the array normal model. Journal of Multivariate Analysis, 137, 32-49. https://doi.org/10.1016/j.jmva.2015.01.020 http://arxiv.org/pdf/1408.0424.pdf

`equi_mcmc`, `random_ortho`.
 ```1 2 3 4 5 6 7 8``` ```# Simulate data. p <- c(5, 5, 5) X <- array(stats::rnorm(prod(p)), dim = p) multi_out <- multiway_takemura(X, mode_rep = 3) multi_out\$b trim(multi_out\$B[[1]]) trim(multi_out\$B[[2]]) trim(multi_out\$B[[3]]) ```