Created
June 19, 2016 12:43
-
-
Save wulingyun/aff10747a268d7cbd0efb151b89dc3f7 to your computer and use it in GitHub Desktop.
Calculate normal test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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