Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate normal test
# one sample normal test
norm_test1 <- function(x.n, x.mu, x.var, mu, side=0)
{
nu <- x.n - 1
z <- (x.mu - mu) / sqrt(x.var / x.n)
p <- p.value(pnorm, z, side=side)
data.frame(mean=x.mu, df=nu, statistic=z, p.value=p)
}
# two samples normal test
norm_test2 <- function(x.n, x.mu, x.var, y.n, y.mu, y.var, side=0)
{
mu <- x.mu - y.mu
nu <- x.n + y.n
z <- mu / sqrt(x.var/x.n + y.var/y.n)
p <- p.value(pnorm, z, side=side)
data.frame(mean=mu, df=nu, statistic=z, p.value=p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment