User Tools

Site Tools


c:ps1:2025:t-test_note:output01

This is an old revision of the document!


> ###
> rnorm2 <- function(n,mean,sd) { 
+   mean+sd*scale(rnorm(n)) 
+   }
> groupA <- rnorm2(10, 19, sqrt(160/9))
> groupB <- rnorm2(10, 25, sqrt(200/9))
> ss.a <- 160
> ss.b <- 200
> n.a <- 10
> n.b <- 10
> df.a <- 9
> df.b <- 9
> pooled.v <- (ss.a+ss.b)/(df.a+df.b)
> pooled.v 
[1] 20
> se <- sqrt(pooled.v/n.a + pooled.v/n.b)
> se
[1] 2
> diff <- (mean(groupA)-mean(groupB))
> t.cal <- diff/se
> t.cal
[1] -3
> pt(t.cal, df=df.a+df.b)*2
[1] 0.007685412
> 
> t.test(groupA, groupB, var.equal=T)

	Two Sample t-test

data:  groupA and groupB
t = -3, df = 18, p-value = 0.007685
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -10.201844  -1.798156
sample estimates:
mean of x mean of y 
       19        25 

> 
> # 만약에 정확한 구간의 probability 보다 
> # 95% confidence interval의 점수를 구하고
> # 싶다면
> t.critical <- abs(qt(.05/2, 18))
> c(-t.critical, t.critical)
[1] -2.100922  2.100922
> t.cal
[1] -3
c/ps1/2025/t-test_note/output01.1764717966.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki