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?