Problem:
Let $X_1,..., X_{n_1} \stackrel{iid}{\sim} \text{Binomial}(n, p_1)$ and $Y_1,..., Y_{n_2} \stackrel{iid}{\sim} \text{Binomial}(n, p_2)$. I want to test the following hypotheses:
$$ H_0: p_1 = p_2 \\ H_A: p_1 \neq p_2 $$
My approach so far:
Let $\hat{p}_1 = \frac{ \sum_{i=1}^{n_1} X_i/n }{n_1}$ and $\hat{p}_2 = \frac{ \sum_{i=1}^{n_2} Y_i/n }{n_2}$. Test if these proportions are equal using a chi-squared test of homogeneity (see here for details).
My questions:
Is there a better way to do this test? Letting $p_1$ and $p_2$ be the averages of all individual proportions feels silly because it ignores the distributions of the proportions.
Could I let $\hat{p}_1 = (X_1/n, ..., X_{n_1}/n)$ and $\hat{p}_2 = (Y_1/n, ..., Y_{n_2}/n)$ and use a non-parametric ANOVA (like the Kruskall-Wallis test) to test if the vectors of proportions are different? Would this approach be better than my initial proposal?