1 |
r1 |
|
n1 |
|
r2 |
|
n2 |
|
x |
|
y |
|
alpha |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (r1 = sum(x), n1 = length(x), r2 = sum(y), n2 = length(y),
x = NA, y = NA, alpha = 0.05)
{
N = n1 + n2
u = 0.5
Dhat = (r1 + 0.5)/(n1 + 1) - (r2 + 0.5)/(n2 + 1)
psihat = ((r1 + 0.5)/(n1 + 1) + (r2 + 0.5)/(n2 + 1))/2
nuhat = (1 - 2 * psihat) * (0.5 - n2/N)
what = sqrt(2 * u * psihat * (1 - psihat) + nuhat^2)
se = qnorm(1 - alpha/2) * sqrt(u/(2 * n1 * n2/N))
val1 = max(c(-1, (u * Dhat + nuhat)/what - se))
ci = what * sin(asin(val1))/u - nuhat/u
val2 = min(c(1, (u * Dhat + nuhat)/what + se))
ci[2] = what * sin(asin(val2))/u - nuhat/u
list(ci = ci, p1 = r1/n1, p2 = r2/n2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.