0

I am comparing my z-score result from weightstats.ztest and hand calculation and get slightly different result, z_package=-12.636 and z_handbook=-13.019.

The z_package is determined by z_package, p = weightstats.ztest(data1, data2) were sample size data1 is 574 and data2 is 1026.

The z_handbook is determined by following code:

y1 = np.array(data1).mean()
y2 = np.array(data2).mean()


s1 = np.array(data1)).std()
s2 = np.array(data2).std()

n1 = len(data1)
n2 = len(data2)

se = math.sqrt(s1**2/n1+s2**2/n2)

dy = y1-y2

z_handbook = (dy-0)/se

I have tried to read about how weightstats.ztest calculate the z-score but cannot find any good explanation . Does anyone have a clue where the z-scores differs?

Zac Hatfield-Dodds
  • 2,455
  • 6
  • 19
Alex K
  • 119
  • 1
  • 9
  • one item, but I don't know if that's all. numpy std uses ddof=0 by default. Try `.std(ddof=1)` – Josef Nov 13 '20 at 00:21
  • second issue: `se` can be pooled under the assumption that variances are equal, or assumed unequal as in your example. – Josef Nov 13 '20 at 00:24
  • @Josef the `.std(ddof=1)` didn't give any difference unfortunately. Yes my hand calculation assume that variances are unqeual but the package assume it is equal I think. This is very annoying – Alex K Nov 13 '20 at 08:07

0 Answers0