# How to calculate the asymptotic p-value for a test on a Poisson i.i.d random variable?

Disclaimer: This is a question I couldn't solve. I feel it is ethical to state this here so you can evaluate how much of your solution will share through either statements or hints.

Let $$X_{1},…,X_n$$ be an $$i.i.d.$$ $$Poiss(\lambda)$$ distributed random variable for some unknown $$\lambda . 0$$. Now consider the following hypothesis test:

$$H_0:λ=λ_0$$ v.s. $$H_1:λ≠λ_0$$ where $$λ_0>0$$.

Question: What is the asymptotic p-value?

Here's what I know:

Let $$\overline{X}_n$$ be the average of the random variable $$X$$. Thanks to the Central Limit Theorem, I can write:

$$\dfrac{|\overline{X}_n - \lambda_0|}{\sigma/\sqrt{n}} \xrightarrow{(d)} N(0,1)$$ as $$n$$ goes to infinity.

Given it's a two-sided test, according to [1] I can write

$$P_{\lambda_0}\left(\dfrac{|\overline{X}_n - \lambda_0|}{\sigma/\sqrt{n}} > z_{\alpha/2}\right)$$ $$\rightarrow \alpha$$

$$P_{\lambda_0}\left(|W| > z_{\alpha/2}\right)$$ $$\rightarrow \alpha$$

where $$W$$ is the Wald Test and $$z_{\alpha/2} = \Phi^{-1}(1 - \alpha/2)$$

Also from [1], I can write

$$p-value = P_{\lambda_0}(|W| > |z_{\alpha/2}|) = 2.\Phi(-|z_{\alpha/2}|)$$

This is where I'm stuck. I know all of these statements are true, however, I cannot work with the knowledge I have to obtain the answer I need. I'm still re-reading about hypothesis testing and p-values to have a better grip on problems like this.

References

[1] Wasserman, Larry. All of statistics: a concise course in statistical inference. Springer Science & Business Media, 2004, second edition.

• The p-value is the biggest $\alpha$ such that the hypothesis test doesn‘t reject, or the smallest $\alpha$ such that the test rejects. Jun 17, 2020 at 21:02

Significance level. Let $$n = 100$$ (sufficiently large that an asymptotic test has a chance) and $$\lambda_0 = 10.$$ Then it seems safe to use $$Z = \frac{\bar X - \mu_0}{\sqrt{\mu_0/n}}$$ as a test statistic, rejecting $$H_0: \mu = 10$$ against $$H_a: \mu \ne 10,$$ at the 5% level if $$|Z| \ge 1.96.$$ [Notice that if $$X \sim \mathsf{Pois}(\lambda),$$ then $$E(X) = Var(X) = \lambda.]$$

set.seed(617)
n = 100;  lam.0 = 10;  se = sqrt(lam.0/n)
a = replicate(10^6, mean(rpois(n,lam.0)))
z = (a-lam.0)/se
mean(abs(z)>=1.96)
[1] 0.051348


This test has nearly the 5% level, as anticipated.

P-value. The P-value is the probability under $$H_0$$ that the test statistic would take a value farther from $$0$$ than observed. Using the R function pnorm (for which the default, without specifying parameters other than 0 or 1, is $$\Phi)$$ we get the following:

pv = pnorm(-abs(z)) + 1 - pnorm(abs(z))
summary(pv)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
0.0000  0.2549  0.5066  0.5000  0.7518  1.0000


In general, under $$H_0$$ for a continuous test statistic, the P-value has a standard uniform distribution. Our test statistic, based on Poisson data, is actually discrete with small increments. Among the $$100\,000$$ simulated tests, there were only 286 uniquely different values of the test statistic $$Z.$$

length(unique(z))
[1] 286


Thus, the histogram of our P-value is only roughly standard uniform. The important thing for testing at the 5% level is that the probability of the left-most bar is nearly 5%.

hist(pv, prob=T, col="skyblue2", main="Histogram of P-values")


Power against specific alternatives. The power of this test against the particular alternative $$\lambda = 12$$ is above 99%.

set.seed(2020)
n = 100;  lam.0 = 10;  se = sqrt(lam.0/n)
a = replicate(10^6, mean(rpois(n,12)))   # alternative 12
z = (a-lam.0)/se
mean(abs(z)>=1.96)
[1] 0.99998


And its power against the particular alternative $$\lambda = 9$$ is about 90%.

set.seed(2021)
n = 100;  lam.0 = 10;  se = sqrt(lam.0/n)
a = replicate(10^6, mean(rpois(n,9)))     # alternative 9
z = (a-lam.0)/se
mean(abs(z)>=1.96)
[1] 0.899814


So for the parameters used in the simulation, the test seems to work as intended.