I have 400,000 rows, each with an id, number of trials, and number of successes.
I have (one) value for p, a hypothesized probability of success.
I'd like to calculate an exact, binomial, one-sided p-value for each ro开发者_如何学Pythonw, using its trials successes, and the global p.
E.g.,
1001 10 2
should give me
1001 10 2 2.639011e-01 for the probability of 2 successes or more.
I'd prefer a solution in SAS, but SPSS is also useful.
Thanks!
You can use the binomial distribution directly:
data yourdata;
set yourdata;
p_lower = PROBBNML(globalp, ntrials, nsuccesses);
p_higher = 1 - PROBBNML(globalp, ntrials, nsuccesses-1);
run;
I have not tested whether PROBBNML will work with -1 responses, so you might need to test for nsuccesses=0
before using the p_higher
formula.
精彩评论