# Sample size calculation for Chi square Test

#### ehi895

##### New Member
Hi, I have trouble determining the sample size for a simple Chi Square Test.
My problem is the following:
I tried to calculate the sample size for two samples whith P1=0.7 and P2=0.9. Unfortunately, the result was different when I used another software. I simulated the data and did the Chi Square test in SPSS and the results were not even close to 0.05 even though I set alpha to 0.05.
My questions are now:
- which software is the best fo sample size calculations?
- what is the appropriate number of cases for this problem for each group?
- how do you calculate the sample size for proportions of more than 2 groups (e.g. 2x3 table)

Thanks so much for your help!

#### mmercker

##### New Member
Hi,

as far as I understand, you want to determine an appropriate sample size N for the Chi^2 Test in order to detect a certain effect size w with a certain alpha, beta and DF-value? I always use G*Power, which is for free.

Best regards

#### hlsmith

##### Omega Contributor
I always hear good things about GPower, but have never used it.

Every program should provide its formula and they should all be comparable - so I don't think there is a best. You probably run into issues with the defaults settings and many options available, plus I am unsure if sample size calculations will be different between trying to power a likelihood ratio or Pearson chi-square. I just run those both and found a difference of 61 versus 62 subjects per group. Also you need to state a reference group many times.

I ran your numbers in SAS and got the following:

The POWER Procedure

Pearson Chi-square Test for Two Proportions
Fixed Scenario Elements Distribution Asymptotic normal Method Normal approximation Group 1 Proportion 0.7
Group 2 Proportion 0.9
Nominal Power 0.8
Number of Sides 2
Null Proportion Difference 0
Alpha 0.05

Group Actual Power 0.803
N per Group 62

I believe simulation could give you more variability in the number generates if the seed is not set - typically using the system clock. To be cautious, don't forget to add on an additional 10% or so if you have any doubts about the sample you may get in comparison to the numbers used to generate the calculations.​