Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAQ: One-sample proportion z-test -- Implementation Issue? #4372

Open
Nolataari opened this issue Mar 21, 2018 · 1 comment
Open

FAQ: One-sample proportion z-test -- Implementation Issue? #4372

Nolataari opened this issue Mar 21, 2018 · 1 comment

Comments

@Nolataari
Copy link

Nolataari commented Mar 21, 2018

In the case of one-sample test, the function proportions_ztest(count, nobs, value=None, alternative='two-sided', prop_var=False) from statsmodels.stats.proportion calculates the variance based on the sample proportion, unless prop_var is specified, like so:

    if prop_var:
        p_pooled = prop_var
    var_ = p_pooled * (1 - p_pooled) * nobs_fact

However, explicitly specifying prop_var is redundant, since in my opinion it should be picked up by the parameter value. I personally do not see a reason why the variance should be calculated by default using the sample proportion instead of the null hypothesis value.

I am keen to hear your opinion on this.

@josef-pkt
Copy link
Member

Both versions are legitimate, it is the difference between wald tests (parameters estimated from the sample without null hypothesis restrictions) and score/LM test (parameters estimated under the null hypothesis restrictions). I followed the documentation of SAS or SPSS or some other package in this. (I don't remember which ones I looked at.)
see also the related number of possibilities to compute confidence intervals for a proportion.

e.g.
http://support.sas.com/documentation/cdl/en/procstat/67528/HTML/default/viewer.htm#procstat_freq_details37.htm section "Equality Test"

The problem is that the score test has better small sample behavior than the wald test. However, at the time I mainly translated formulas to code and hadn't read yet much about the small sample behavior of those hypothesis test and related statistics.

@josef-pkt josef-pkt changed the title One-sample proportion z-test -- Implementation Issue? FAQ: One-sample proportion z-test -- Implementation Issue? Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants