Test whether difference in proportions differs from a non-zero constant I am using the prop.test function in R to test the differences of proportions against the alternative that the difference of the two proportions are significantly different from zero, however I wish to perform the same test, but instead of testing if they are significantly different from zero I want to test if they are different from some constant (lets say C) where more often then not C is not equal to 0.
Does anyone know of a function in R to do this?
 A: The standard formula for testing equality of 2 proportions (using the normal approximation) uses a pooled estimate of the proportion that is appropriate when the null of equal proportions is true.  In your case the proportions are not equal, so the pooled proportion is not appropriate.
One option is that you can code the formula that does not pool the proportion, then compute the p-value, etc. from the normal approximation.
Another option is to just use prop.test but ignore the p-value part and look to see if the confidence interval includes the C value that you are interested in. If C is not in the interval then that is equivalent to rejecting the null and if C is in the interval then that is equivalent of a p-value greater than alpha (not enough evidence to reject).  You don't get an exact p-value, but you get the same decision.
A: A test for difference between proportions is as follows:
$H_0: p_2 - p_1 = C $
$H_A: p_2 - p_1 \neq C$
Then the test statistic is:
$$Z = \frac{(\hat{p}_2 - \hat{p}_1) - C}{\sqrt{\frac{\hat{p}_1(1-\hat{p}_1)}{n_1} + \frac{\hat{p}_2(1-\hat{p}_2)}{n_2}}} $$
The following R code ought to work:
SE = sqrt((p1*(1-p1)/n1 + p2*(1-p2)/n2))
z = ((p1 - p2) - C)/SE
1 - pnorm(abs(z))

Note: For this test to be appropriate, each sample much be independent and random, and must have at least 10 successes and 10 failures.  It's also problematic when $p_i$ or $1-p_i$ is close to zero.  Thanks to @whuber for pointing out these requirements.
