def test_ztost(): xfair = np.repeat([1, 0], [228, 762 - 228]) # comparing to SAS last output at # http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sect028.htm # confidence interval for tost # generic ztost is moved to weightstats from statsmodels.stats.weightstats import zconfint, ztost ci01 = zconfint(xfair, alpha=0.1, ddof=0) assert_almost_equal(ci01, [0.2719, 0.3265], 4) res = ztost(xfair, 0.18, 0.38, ddof=0) assert_almost_equal(res[1][0], 7.1865, 4) assert_almost_equal(res[2][0], -4.8701, 4) assert_array_less(res[0], 0.0001)
def test_ztost(): xfair = np.repeat([1,0], [228, 762-228]) # comparing to SAS last output at # http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sect028.htm # confidence interval for tost # generic ztost is moved to weightstats from statsmodels.stats.weightstats import zconfint, ztost ci01 = zconfint(xfair, alpha=0.1, ddof=0) assert_almost_equal(ci01, [0.2719, 0.3265], 4) res = ztost(xfair, 0.18, 0.38, ddof=0) assert_almost_equal(res[1][0], 7.1865, 4) assert_almost_equal(res[2][0], -4.8701, 4) assert_array_less(res[0], 0.0001)
2 blue medium 44 2 blue dark 40 2 blue black 6 2 green fair 50 2 green red 31 2 green medium 37 2 green dark 23 2 brown fair 56 2 brown red 42 2 brown medium 53 2 brown dark 54 2 brown black 13''' dta0 = np.array(ss.split()).reshape(-1,4) dta = np.array(map(tuple, dta0.tolist()), dtype=[('Region', int), ('Eyes', 'S6'), ('Hair', 'S6'), ('Count', int)]) xfair = np.repeat([1,0], [228, 762-228]) # comparing to SAS last output at # http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sect028.htm # confidence interval for tost ci01 = smw.confint_ztest(xfair, alpha=0.1) assert_almost_equal(ci01, [0.2719, 0.3265], 4) res = smw.ztost(xfair, 0.18, 0.38) assert_almost_equal(res[1][0], 7.1865, 4) assert_almost_equal(res[2][0], -4.8701, 4) nn = np.arange(200, 351) pow_z = sms.power_ztost_prop(0.5, 0.72, nn, 0.6, alpha=0.05) pow_bin = sms.power_ztost_prop(0.5, 0.72, nn, 0.6, alpha=0.05, dist='binom') import matplotlib.pyplot as plt plt.plot(nn, pow_z[0], label='normal') plt.plot(nn, pow_bin[0], label='binomial') plt.legend(loc='lower right') plt.title('Proportion Equivalence Test: Power as function of sample size') plt.xlabel('Number of Observations') plt.ylabel('Power')
2 green dark 23 2 brown fair 56 2 brown red 42 2 brown medium 53 2 brown dark 54 2 brown black 13''' dta0 = np.array(ss.split()).reshape(-1, 4) dta = np.array(lmap(tuple, dta0.tolist()), dtype=[('Region', int), ('Eyes', 'S6'), ('Hair', 'S6'), ('Count', int)]) xfair = np.repeat([1, 0], [228, 762 - 228]) # comparing to SAS last output at # http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sect028.htm # confidence interval for tost ci01 = smw.confint_ztest(xfair, alpha=0.1) assert_almost_equal(ci01, [0.2719, 0.3265], 4) res = smw.ztost(xfair, 0.18, 0.38) assert_almost_equal(res[1][0], 7.1865, 4) assert_almost_equal(res[2][0], -4.8701, 4) nn = np.arange(200, 351) pow_z = sms.power_ztost_prop(0.5, 0.72, nn, 0.6, alpha=0.05) pow_bin = sms.power_ztost_prop(0.5, 0.72, nn, 0.6, alpha=0.05, dist='binom') import matplotlib.pyplot as plt plt.plot(nn, pow_z[0], label='normal') plt.plot(nn, pow_bin[0], label='binomial') plt.legend(loc='lower right') plt.title('Proportion Equivalence Test: Power as function of sample size') plt.xlabel('Number of Observations') plt.ylabel('Power')