Skip to content

Instantly share code, notes, and snippets.

@wulingyun
Created Jun 19, 2016
Embed
What would you like to do?
Calculate P-value
p_value <- function(cdf, z, params=numeric(0), side=0)
{
n <- length(params)
p <- switch(n+1,
cdf(z),
cdf(z, params),
cdf(z, params[1], params[2]),
cdf(z, params[1], params[2], params[3])
)
if (side < 0) p
else if (side > 0) 1-p
else if (p < 1/2) 2*p
else 2*(1-p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment