I have two independent poisson random variables, $X_1$ and $X_2$, with $X_1 \sim \text{Pois}(\lambda_1)$ and $X_2 \sim \text{Pois}(\lambda_2)$. I want to test $H_0:\, \lambda_1 = \lambda_2$ versus the alternative $H_1:\, \lambda_1 \neq \lambda_2$.
I already derived maximum likelihood estimates under null and alternate hypothesis (model), and based on those I calculated likelihood ratio test (LRT) statistic (R codes given below).
Now I am interested to calculate power of the test based on:
- Fixed alpha (type 1 error) = 0.05.
- Using different sample sizes (n), say n = 5, 10, 20, 50, 100.
- Different combination of $\lambda_1$ and $\lambda_2$, which will change LRT statistics (computed as
LRTstat
below).
Here is my R code:
X1 = rpois(λ1); X2 = rpois(λ2)
Xbar = (X1+X2)/2
LLRNum = dpois(X1, X1) * dpois(X2, X2)
LLRDenom = dpois(X1, Xbar) * dpois(X2, Xbar)
LRTstat = 2*log(LLRNum/LLRDenom)
From here, how could I proceed with power calculation (preferably in R)?