I am using a parametric bootstrap/monte carlo hypothesis testing method to generate the null distribution of the log likelihood ratio statistic. However, I am worried I might be doing it wrong because about half of likelihood ratio statistics calculated on my simulated data are zero, meaning I never get any p-values between 1 and 0.5.
My null hypothesis is that the data comes from an i.i.d. normal distribution, and my alternate hypothesis is that the data comes from a convex combination of two multivariate normal distributions parameterized by $\lambda$ as follows: $\sigma_{1}^{2}(\lambda A_{n}+(1-\lambda)\mathbb{I}_{n})$, where $A_{n}$ is the variance-covariance matrix describing the correlation between any two observations $x_{i}$ and $x_{j}$ and $\mathbb{I}_{n}$ is the identity matrix, and $\lambda$ is restricted to $[0,1]$.
For my given data set, I estimate the variance under the null hypothesis according to $(1/(n-1))\sum_i(x_{i}-x_{mean})^{2}$. Then I generate 999 datasets each of size n from a normal distribution with the variance I just estimated. Then for each of these datasets I fit the $\lambda$ value by maximum likelihood and compare it to the maximum likelihood value of the nested hypothesis which fixes $\lambda=0$. Then having calculated the ratio on 999 simulated datasets, I can calculate the the p-value by counting how many log likelihood ratio values are greater than or equal to that on the original dataset.
The problem is, more than half of the log likelihood ratios are exactly zero. Is this the result of some sort of mistake I'm making? Or is it possible for the distribution of log likelihood ratios to have such a weird distribution? And in this case are the p-values reliable?
EDIT 1: (I'm actively editing this and will remove this warning when I finish.): Thanks all for your speculation, here is an example of $A_{n}$ derived from the spatial structure of ten samples, n=10.
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1.0000 0.9416 0.7284 0.7284 0.5834 0.5834 0.5834 0.0014 0.0000 0.0000
[2,] 0.9416 1.0000 0.7284 0.7284 0.5834 0.5834 0.5834 0.0014 0.0000 0.0000
[3,] 0.7284 0.7284 1.0000 0.9213 0.5834 0.5834 0.5834 0.0014 0.0000 0.0000
[4,] 0.7284 0.7284 0.9213 1.0000 0.5834 0.5834 0.5834 0.0014 0.0000 0.0000
[5,] 0.5834 0.5834 0.5834 0.5834 1.0000 0.9168 0.6186 0.0014 0.0000 0.0000
[6,] 0.5834 0.5834 0.5834 0.5834 0.9168 1.0000 0.6186 0.0014 0.0000 0.0000
[7,] 0.5834 0.5834 0.5834 0.5834 0.6186 0.6186 1.0000 0.0014 0.0000 0.0000
[8,] 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 1.0000 0.0000 0.0000
[9,] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 0.8664
[10,] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.8664 1.0000
While this "toy" example of $A_{n}$ above is given for demonstration purposes, to test the suggestion jbowman that I allow $\lambda$ to be negative, I'm going to use
A_n<-matrix(c(1,0.3,0.3,0.3,0.3,0.3,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,1,0.72,0.72,0.54,0.54,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.72,1,0.79,0.54,0.54,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.72,0.79,1,0.54,0.54,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.54,0.54,0.54,1,0.83,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.54,0.54,0.54,0.83,1,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.15,0.15,0.15,0.15,0.15,0.15,1,0.92,0.91,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.15,0.15,0.15,0.15,0.15,0.15,0.92,1,0.91,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.15,0.15,0.15,0.15,0.15,0.15,0.91,0.91,1,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,1,0.4,0.4,0.4,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.4,1,0.6,0.6,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.4,0.6,1,0.9,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.4,0.6,0.9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0.43,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0,0,0,0,0,0,0,0,0,0,0,0,0,0.43,1,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,1,1,0.76,0.76,0.76,0.76,0.76,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,1,1,0.76,0.76,0.76,0.76,0.76,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,1,0.99,0.89,0.89,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.99,1,0.89,0.89,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.89,0.89,1,0.97,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.89,0.89,0.97,1,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.79,0.79,0.79,0.79,1,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.71,0.71,0.71,0.71,0.71,0.71,0.71,1,0.86,0.86,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.86,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.86,1,1),25,25)
where $A_{n}$ is (25 x 25) just like in jbowman's example below. Thus I will run the following code:
A_n<-matrix(c(1,0.3,0.3,0.3,0.3,0.3,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,1,0.72,0.72,0.54,0.54,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.72,1,0.79,0.54,0.54,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.72,0.79,1,0.54,0.54,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.54,0.54,0.54,1,0.83,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.3,0.54,0.54,0.54,0.83,1,0.15,0.15,0.15,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.15,0.15,0.15,0.15,0.15,0.15,1,0.92,0.91,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.15,0.15,0.15,0.15,0.15,0.15,0.92,1,0.91,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.15,0.15,0.15,0.15,0.15,0.15,0.91,0.91,1,0.08,0.08,0.08,0.08,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,1,0.4,0.4,0.4,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.4,1,0.6,0.6,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.4,0.6,1,0.9,0,0,0,0,0,0,0,0,0,0,0,0,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.4,0.6,0.9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0.43,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0,0,0,0,0,0,0,0,0,0,0,0,0,0.43,1,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0.18,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,1,1,0.76,0.76,0.76,0.76,0.76,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,1,1,0.76,0.76,0.76,0.76,0.76,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,1,0.99,0.89,0.89,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.99,1,0.89,0.89,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.89,0.89,1,0.97,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.89,0.89,0.97,1,0.79,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.76,0.76,0.79,0.79,0.79,0.79,1,0.71,0.71,0.71,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.71,0.71,0.71,0.71,0.71,0.71,0.71,1,0.86,0.86,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.86,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0.18,0.18,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.86,1,1),25,25)
I_n <- diag(1,25)
func <- function(lambda, x) {
S <- lambda*A_n + (1-lambda)*I_n
retval <- mvtnorm::dmvnorm(x, mean=rep(0,25), sigma=S, log=TRUE)
}
mle <- rep(0,1000)
mle2<- rep(0,1000)
for (i in seq_along(mle)) {
x <- rnorm(25)
res <- optimize(func, lower=0, upper=1, maximum=TRUE, x=x)
mle[i] <- res$maximum
# I think -0.14 is the correct "true" lower limit:
res2<- optimize(func, lower=-0.14, upper=1, maximum=TRUE, x=x)
mle2[i]<- res2$maximum
}
summary(mle)
summary(mle2)
hist(mle)
hist(mle2)
Notice that for my type of $A_{n}$ I can replicate the results shown in this answer for my problem where $\lambda$ is constrained in $[0,1]$. However, one potentially strange thing is that when I allow $\lambda$ to take on negative values, despite the data generating process using $\lambda$ equals zero, the actual mode of the estimate is the limiting negative value (-0.14 for this specific $A_{n}$ matrix), though the mean and median are both close to zero.
summary(mle)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
#0.0000408 0.0000614 0.0000763 0.1007287 0.1293151 0.9183230
summary(mle2)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
#-0.13996 -0.12253 -0.03151 0.04491 0.12745 0.91830