Skip to content

Commit

Permalink
update T test
Browse files Browse the repository at this point in the history
  • Loading branch information
angeella committed Jul 8, 2020
1 parent 7c127c7 commit 75eef78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions R/oneSample.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ oneSample<- function(X,alternative = "two.sided"){
#Test = rowMeans(X)/(sqrt((rowV)/n))
Test <- ifelse(rowV==0,0, rowMeans(X)/(sqrt((rowV)/n)))
pv <- switch(alternative,
"two.sided" = 2*(pt(abs(Test), df = n-1, lower.tail=FALSE)),
"greater" = pt(Test, df = n-1, lower.tail=FALSE),
"lower" = 1-pt(Test, df = n-1, lower.tail=FALSE))
"two.sided" = 2*(pnorm(abs(Test), lower.tail=FALSE)),
"greater" = pnorm(Test, lower.tail=FALSE),
"lower" = 1-pnorm(Test, lower.tail=FALSE))

res <- list(Test = Test, pv = pv)

Expand Down
12 changes: 6 additions & 6 deletions R/signTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ signTest <- function(X, B = 999, alternative = "two.sided", seed = NULL, mask =

if(!rand){
pv <- switch(alternative,
"two.sided" = 2*(pt(abs(Test), df = n-1, lower.tail=FALSE)),
"greater" = pt(Test, df = n-1, lower.tail=FALSE),
"lower" = 1-pt(Test, df = n-1, lower.tail=FALSE))
"two.sided" = 2*(pnorm(abs(Test), lower.tail=FALSE)),
"greater" = pnorm(Test, lower.tail=FALSE),
"lower" = 1-pnorm(Test, lower.tail=FALSE))

pv_H0 <- switch(alternative,
"two.sided" = 2*(pt(abs(Test_H0), df = n-1, lower.tail=FALSE)),
"greater" = pt(Test_H0, df = n-1, lower.tail=FALSE),
"lower" = 1-pt(Test_H0, df = n-1, lower.tail=FALSE))
"two.sided" = 2*(pnorm(abs(Test_H0), lower.tail=FALSE)),
"greater" = pnorm(Test_H0, lower.tail=FALSE),
"lower" = 1-pnorm(Test_H0, lower.tail=FALSE))
}else{

Test_matrix <- cbind(Test, Test_H0)
Expand Down

0 comments on commit 75eef78

Please sign in to comment.