# Are there any statistical tests that are implemented in R for testing whether a matrix is positive semi-definite and of the right rank?

I'm working on utility functions for discrete choice modelling, preferences are often modelled using quadratic preferences, which look like $$u(z) = a + q'z - z'rz$$ where $$z$$ are a vector of attributes, $$q$$ is a vector of parameters, $$a$$ is a constant and $$r$$ is a $$n$$ x $$n$$ parameter matrix. In this case if $$r$$ is of full rank and positive semi-definite, then there is an "ideal point" away from which utility declines monotonically.

We obtain $$u(z) = \sum_j (q_j z_j + r_{j,j}z_j^2 + \sum_{k \neq j} r_{j,k} z_j z_k)$$ If we assume a person only chooses an option if $$u(z)>0$$ then we can obtain $$\widehat{r}$$ through regressing which option was chosen on its set of attributes $$z$$, the squares of the elements of $$z$$, and the two-way interactions of the elements of $$z$$.

Now, if I wanted to calculate if a given sample for $$r$$ drawn from data, let's say $$\widehat{r}$$ is actually positive semi-definite, then I can do that by calculating the eigenvalues, through for example the package matrixcalc.

But what if I want to run a statistical test for semi-definiteness or full rank, which one might think of as a null hypothesis that none of the eigenvalues are zero? The reason for running a statistical test is its the semi-definiteness and full rank of $$r$$, rather than $$\widehat{r}$$ which is of interest.

I can see for instance there's tests like the one here https://www.ecb.europa.eu/pub/pdf/scpwps/ecbwp850.pdf, but can't find any implementations in R.

• The article is behind a paywall. But .... I'm confused. I thought that the definitieness (if that's the word) of a matrix was what it was, and that there was no stochastic element. How could a statistical test be relevant? (As you say, you calculate it). What am I missing? Oct 11, 2023 at 11:30
• Well what I mean is the matrix itself is calculated with some uncertainty, because the parameters in it are uncertain -- so whether the sample matrix is definite is certainly feasible, but you need a statistical test for the population matrix, rather than the sample one you have. Oct 11, 2023 at 14:06
• @PeterFlom have now clarified it through an edit, hopefully. Oct 11, 2023 at 14:09
• Can you tell us anything about how $\hat r$ is generated? Oct 11, 2023 at 19:35
• Hi John I've added that now Oct 12, 2023 at 21:24