c:ms:2023:schedule:week06_t-test_and_anova_note
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| c:ms:2023:schedule:week06_t-test_and_anova_note [2023/04/11 23:02] – [R] hkimscil | c:ms:2023:schedule:week06_t-test_and_anova_note [2024/04/07 23:42] (current) – [output] hkimscil | ||
|---|---|---|---|
| Line 73: | Line 73: | ||
| df.b <- n.b - 1 | df.b <- n.b - 1 | ||
| - | pooled.var <- (SSa+SSb)/ | + | # we know that we are testing the difference |
| + | # between two independent sample means. | ||
| + | # Hence, we need to use poole variance between | ||
| + | # the two group. See | ||
| + | # http:// | ||
| + | pooled.var <- (SSa + SSb) / (df.a + df.b) | ||
| se <- sqrt(pooled.var/ | se <- sqrt(pooled.var/ | ||
| - | t.calculated <- diff/se | + | # Remember t test calculation is based on |
| + | # diff / random error | ||
| + | t.calculated <- diff / se | ||
| pooled.var | pooled.var | ||
| + | diff | ||
| se | se | ||
| t.calculated | t.calculated | ||
| + | # Now use t.test function for two group | ||
| + | # (independent sample) t-test | ||
| + | # with an assumption that variances of | ||
| + | # the two gorup are the same. | ||
| t.result <- t.test(A, B, var.equal = T) | t.result <- t.test(A, B, var.equal = T) | ||
| t.result | t.result | ||
| + | |||
| + | # t.result$statistic = t.calculated | ||
| + | # t.result$p.value = probability level of | ||
| + | # wrong decision with the t calculated value | ||
| + | str(t.result) | ||
| t.result$statistic | t.result$statistic | ||
| t.result$p.value | t.result$p.value | ||
| - | p.value <- 2*pt(-t.result$statistic, | + | # the above p.value can be obtained with |
| + | # pt function | ||
| + | p.value <- 2*pt(-t.result$statistic, | ||
| p.value | p.value | ||
| - | str(t.result) | ||
| t.result$p.value | t.result$p.value | ||
| Line 95: | Line 113: | ||
| # | # | ||
| + | # A combined group with group A and B | ||
| + | # We call it group total | ||
| + | # we can obtain its mean, variance, ss, df, etc. | ||
| + | # | ||
| A | A | ||
| B | B | ||
| Line 100: | Line 122: | ||
| dat | dat | ||
| + | mean.total <- mean(dat) | ||
| var.total <- var(dat) | var.total <- var(dat) | ||
| + | # variance를 ms라고 부르기도 한다 | ||
| + | ms.total <- var.total | ||
| + | |||
| df.total <- length(dat)-1 | df.total <- length(dat)-1 | ||
| ss.total <- var.total*df.total | ss.total <- var.total*df.total | ||
| ss.total.check <- sum((dat-mean(dat))^2) | ss.total.check <- sum((dat-mean(dat))^2) | ||
| + | |||
| + | mean.total | ||
| + | var.total | ||
| + | ms.total | ||
| + | df.total | ||
| ss.total | ss.total | ||
| ss.total.check | ss.total.check | ||
| - | mean.total <- mean(dat) | ||
| - | mean.total | ||
| + | # Now for each group | ||
| mean.a <- mean(A) | mean.a <- mean(A) | ||
| mean.b <- mean(B) | mean.b <- mean(B) | ||
| + | mean.a | ||
| + | mean.b | ||
| + | |||
| + | # 그룹 간의 차이에서 나타나는 분산 | ||
| + | # 수업시간에 설명을 잘 들을 것 | ||
| # mean.total 에서 그룹a의 평균까지의 차이를 구한 후 | # mean.total 에서 그룹a의 평균까지의 차이를 구한 후 | ||
| - | # 이를 제곱하여 A의 숫자만큼 더한다 = | + | # 이를 제곱하여 |
| # 즉, SS를 구하는 방법. | # 즉, SS를 구하는 방법. | ||
| # 전체평균에서 그룹평균을 뺀 것의 제곱을 | # 전체평균에서 그룹평균을 뺀 것의 제곱을 | ||
| # 그룹 구성원 숫자만큼 더하는 것 | # 그룹 구성원 숫자만큼 더하는 것 | ||
| + | # 그리고 이들을 다시 모두 더하여 | ||
| + | # ss.between에 저장 | ||
| + | length(A) * ((mean.total - mean.a)^2) | ||
| + | length(B) * ((mean.total - mean.b)^2) | ||
| - | length(A)*((mean.total - mean.a)^2) | ||
| - | length(B)*((mean.total - mean.b)^2) | ||
| ss.between <- | ss.between <- | ||
| length(A)*((mean.total - mean.a)^2) + | length(A)*((mean.total - mean.a)^2) + | ||
| length(B)*((mean.total - mean.b)^2) | length(B)*((mean.total - mean.b)^2) | ||
| - | |||
| ss.between | ss.between | ||
| + | # df between group은 연구에 사용된 | ||
| + | # 그룹의 숫자에서 1을 뺀 숫자 | ||
| + | df.between <- 2 - 1 | ||
| + | # 이 그룹 간 차이에 기인하는 분산 값은 | ||
| + | ms.between <- ss.between / df.between | ||
| # 한편 ss.a 와 ss.b는 각 그룹 내의 | # 한편 ss.a 와 ss.b는 각 그룹 내의 | ||
| Line 132: | Line 173: | ||
| ss.b <- var(B) * df.b | ss.b <- var(B) * df.b | ||
| ss.within <- ss.a + ss.b | ss.within <- ss.a + ss.b | ||
| - | + | df.a <- length(A)-1 | |
| - | # Now check this | + | df.b <- length(B)-1 |
| - | ss.total | + | |
| - | ss.between | + | |
| - | ss.within | + | |
| - | ss.total == ss.between + ss.within | + | |
| - | + | ||
| - | # 한편 df는 | + | |
| - | # df.total | + | |
| - | df.between <- 2-1 # 그룹숫자 - 1 | + | |
| - | df.a <- length(A)-1 # a 구성원 | + | |
| - | df.b <- length(B)-1 # b 구성원 | + | |
| df.within <- df.a + df.b | df.within <- df.a + df.b | ||
| + | ms.within <- ss.within / df.within | ||
| - | df.total | + | # 여기까지 우리는 |
| - | df.between | + | # 전체분산 |
| - | df.within | + | # 그룹간분산 |
| - | df.total == df.between + df.within | + | # 그룹내분산 |
| - | + | # 구한 것 | |
| - | # 분산을 구하는 방법은 SS/df 이므로 | + | |
| - | # 분산을 | + | |
| - | # ms.total, ms.between, ms.within을 | + | |
| - | + | ||
| - | ms.total <- ss.total / df.total | + | |
| - | ms.between <- ss.between / df.between | + | |
| - | ms.within <- ss.within / df.within | + | |
| - | # 위에서 | + | # ms.between은 그룹의 차이때문에 생긴 |
| # 분산으로 IV 혹은 treatment 때문에 생기는 | # 분산으로 IV 혹은 treatment 때문에 생기는 | ||
| # 차이에 기인하는 분산이고 | # 차이에 기인하는 분산이고 | ||
| Line 169: | Line 194: | ||
| # t test 때와 마찬가지로 | # t test 때와 마찬가지로 | ||
| # 그룹의 차이 / 랜덤 차이를 (에러 -> 분산은 에러라고도 했다) | # 그룹의 차이 / 랜덤 차이를 (에러 -> 분산은 에러라고도 했다) | ||
| - | # 구해볼 수 있다. | + | # 구해볼 수 있다. |
| - | # 이를 프린트아웃 한다 | + | |
| + | # 즉, 그룹갑분산은 사실 = diff (between groups) | ||
| + | # 그리고 그룹내 분산은 사실 = re | ||
| + | # 따라서 우리는 위 둘 간의 비율을 t test와 같이 | ||
| + | # 살펴볼 수 있다 | ||
| + | |||
| + | |||
| + | # 이것을 f.calculated 이라고 하고 | ||
| f.calculated <- ms.between / ms.within | f.calculated <- ms.between / ms.within | ||
| + | # 이 값을 출력해 본다 | ||
| f.calculated | f.calculated | ||
| + | # 이 계산은 차이와 랜덤에러의 비율이 | ||
| + | # df에 따라서 얼마나 되어야 그 차이가 | ||
| + | # 충분히 큰 것인지를 판단하기 위해서 | ||
| + | # 쓰인다. 여기서 df에는 두 가지 종류가 | ||
| + | # 있다. df.between 그리고 df.within | ||
| + | # percentage of f distribution with | ||
| + | # df1 and df2 option | ||
| + | # 이는 그림의 왼쪽을 나타내므로 | ||
| + | # 차이가 점점 커지게 되는 오른쪽을 | ||
| + | # 계산하기 위해서는 1-x를 취한다 | ||
| + | f.calculated.pvalue <- 1-pf(f.calculated, | ||
| + | f.calculated.pvalue | ||
| # 한편, | # 한편, | ||
| # samples t-test를) 아웃 풋은 | # samples t-test를) 아웃 풋은 | ||
| t.result | t.result | ||
| + | # 그리고 f 계산에서의 p value는 t test에서의 p.value와 같다 | ||
| + | f.calculated.pvalue | ||
| + | t.result$p.value | ||
| + | |||
| + | # 또한 | ||
| # 여기엣 t 값은 t.result$statistic 으로 프린트아웃할 수 있다 | # 여기엣 t 값은 t.result$statistic 으로 프린트아웃할 수 있다 | ||
| # 이 값이 2.33333 이었다 | # 이 값이 2.33333 이었다 | ||
| Line 194: | Line 243: | ||
| t.calculated | t.calculated | ||
| + | # Now check this | ||
| + | ss.total | ||
| + | ss.between | ||
| + | ss.within | ||
| + | ss.total | ||
| + | ss.between + ss.within | ||
| + | |||
| + | # 한편 df는 | ||
| + | # df.total | ||
| + | df.total | ||
| + | df.between | ||
| + | df.within | ||
| + | df.total | ||
| + | df.between + df.within | ||
| # 한 편 | # 한 편 | ||
| Line 229: | Line 292: | ||
| sqrt(a.res.sum[[1]][1, | sqrt(a.res.sum[[1]][1, | ||
| t.result$statistic | t.result$statistic | ||
| + | |||
| + | |||
| + | |||
| </ | </ | ||
| ====== output ====== | ====== output ====== | ||
| < | < | ||
| + | > # from the quiz questions | ||
| + | > # stu should understand the logic of the ttest | ||
| + | > | ||
| + | > set.seed(101) | ||
| + | > rnorm2 <- function(n, | ||
| + | > A <- rnorm2(16, 26, sqrt(1160/ | ||
| + | > B <- rnorm2(16, 19, sqrt(1000/ | ||
| + | > A <- c(A) | ||
| + | > B <- c(B) | ||
| + | > # we know sqrt(1160/ | ||
| + | > # hence, A's var is sqrt(1160/ | ||
| + | > # hence, A's SS is sqrt(1160/ | ||
| + | > # this is 1160 | ||
| + | > | ||
| + | > # from the above, | ||
| + | > # the difference between the A and B means | ||
| + | > # remember we try to find | ||
| + | > # difference due to the treatment / | ||
| + | > # / random chance of error | ||
| + | > diff <- 26 - 19 | ||
| + | > | ||
| + | > # for se | ||
| + | > # we know that the situation refers to | ||
| + | > # #2 se two independent samples t-test | ||
| + | > # which is sqrt(pooled.var/ | ||
| + | > | ||
| + | > SSa <- 1160 | ||
| + | > SSb <- 1000 | ||
| + | > n.a <- 16 | ||
| + | > n.b <- 16 | ||
| + | > df.a <- n.a - 1 | ||
| + | > df.b <- n.b - 1 | ||
| + | > | ||
| + | > # we know that we are testing the difference | ||
| + | > # between two independent sample means. | ||
| + | > # Hence, we need to use poole variance between | ||
| + | > # the two group. See | ||
| + | > # http:// | ||
| + | > pooled.var <- (SSa + SSb) / (df.a + df.b) | ||
| + | > se <- sqrt(pooled.var/ | ||
| + | > # Remember t test calculation is based on | ||
| + | > # diff / random error | ||
| + | > t.calculated <- diff / se | ||
| + | > pooled.var | ||
| + | [1] 72 | ||
| + | > diff | ||
| + | [1] 7 | ||
| + | > se | ||
| + | [1] 3 | ||
| + | > t.calculated | ||
| + | [1] 2.333333 | ||
| + | > | ||
| + | > # Now use t.test function for two group | ||
| + | > # (independent sample) t-test | ||
| + | > # with an assumption that variances of | ||
| + | > # the two gorup are the same. | ||
| + | > t.result <- t.test(A, B, var.equal = T) | ||
| + | > t.result | ||
| + | |||
| + | Two Sample t-test | ||
| + | |||
| + | data: A and B | ||
| + | t = 2.3333, df = 30, p-value = 0.02652 | ||
| + | alternative hypothesis: true difference in means is not equal to 0 | ||
| + | 95 percent confidence interval: | ||
| + | 0.8731826 13.1268174 | ||
| + | sample estimates: | ||
| + | mean of x mean of y | ||
| + | | ||
| + | |||
| + | > | ||
| + | > # t.result$statistic = t.calculated | ||
| + | > # t.result$p.value = probability level of | ||
| + | > # wrong decision with the t calculated value | ||
| + | > str(t.result) | ||
| + | List of 10 | ||
| + | $ statistic | ||
| + | ..- attr(*, " | ||
| + | $ parameter | ||
| + | ..- attr(*, " | ||
| + | $ p.value | ||
| + | $ conf.int | ||
| + | ..- attr(*, " | ||
| + | $ estimate | ||
| + | ..- attr(*, " | ||
| + | $ null.value : Named num 0 | ||
| + | ..- attr(*, " | ||
| + | $ stderr | ||
| + | $ alternative: | ||
| + | $ method | ||
| + | $ data.name | ||
| + | - attr(*, " | ||
| + | > t.result$statistic | ||
| + | | ||
| + | 2.333333 | ||
| + | > t.result$p.value | ||
| + | [1] 0.02652366 | ||
| + | > | ||
| + | > # the above p.value can be obtained with | ||
| + | > # pt function | ||
| + | > p.value <- 2*pt(-t.result$statistic, | ||
| + | > p.value | ||
| + | | ||
| + | 0.02652366 | ||
| + | > t.result$p.value | ||
| + | [1] 0.02652366 | ||
| + | > | ||
| > ## | > ## | ||
| > | > | ||
| Line 238: | Line 411: | ||
| > # | > # | ||
| > | > | ||
| + | > # A combined group with group A and B | ||
| + | > # We call it group total | ||
| + | > # we can obtain its mean, variance, ss, df, etc. | ||
| + | > # | ||
| > A | > A | ||
| - | [1] 20.994218 31.148068 16.961481 27.240217 28.354539 | + | [1] 20.994218 31.148068 16.961481 27.240217 28.354539 |
| - | [7] 31.914700 23.459605 35.361796 22.182136 30.847396 15.575648 | + | [6] 38.331534 |
| - | [13] 41.264878 | + | [11] 30.847396 15.575648 41.264878 |
| + | [16] 22.527973 | ||
| > B | > B | ||
| - | [1] 12.941146 21.270062 13.235378 | + | [1] 12.941146 21.270062 13.235378 |
| - | [7] 18.276359 | + | [6] 27.231465 |
| - | [13] 25.018756 25.302096 28.941002 23.293888 | + | [11] 25.017185 19.639663 25.018756 25.302096 28.941002 |
| + | [16] 23.293888 | ||
| > dat <- c(A,B) | > dat <- c(A,B) | ||
| > dat | > dat | ||
| - | [1] 20.994218 31.148068 16.961481 27.240217 28.354539 38.331534 | + | [1] 20.994218 31.148068 16.961481 27.240217 28.354539 |
| - | | + | |
| - | [13] 41.264878 | + | [11] 30.847396 15.575648 41.264878 |
| - | [19] 13.235378 | + | [16] 22.527973 12.941146 21.270062 13.235378 |
| - | [25] 27.560815 | + | [21] 19.232163 27.231465 18.276359 |
| + | [26] | ||
| [31] 28.941002 23.293888 | [31] 28.941002 23.293888 | ||
| > | > | ||
| + | > mean.total <- mean(dat) | ||
| > var.total <- var(dat) | > var.total <- var(dat) | ||
| + | > # variance를 ms라고 부르기도 한다 | ||
| + | > ms.total <- var.total | ||
| + | > | ||
| > df.total <- length(dat)-1 | > df.total <- length(dat)-1 | ||
| > ss.total <- var.total*df.total | > ss.total <- var.total*df.total | ||
| > ss.total.check <- sum((dat-mean(dat))^2) | > ss.total.check <- sum((dat-mean(dat))^2) | ||
| + | > | ||
| + | > mean.total | ||
| + | [1] 22.5 | ||
| + | > var.total | ||
| + | [1] 82.32258 | ||
| + | > ms.total | ||
| + | [1] 82.32258 | ||
| + | > df.total | ||
| + | [1] 31 | ||
| > ss.total | > ss.total | ||
| [1] 2552 | [1] 2552 | ||
| > ss.total.check | > ss.total.check | ||
| [1] 2552 | [1] 2552 | ||
| - | > mean.total <- mean(dat) | ||
| - | > mean.total | ||
| - | [1] 22.5 | ||
| > | > | ||
| + | > # Now for each group | ||
| > mean.a <- mean(A) | > mean.a <- mean(A) | ||
| > mean.b <- mean(B) | > mean.b <- mean(B) | ||
| + | > mean.a | ||
| + | [1] 26 | ||
| + | > mean.b | ||
| + | [1] 19 | ||
| + | > | ||
| + | > # 그룹 간의 차이에서 나타나는 분산 | ||
| + | > # 수업시간에 설명을 잘 들을 것 | ||
| > | > | ||
| > # mean.total 에서 그룹a의 평균까지의 차이를 구한 후 | > # mean.total 에서 그룹a의 평균까지의 차이를 구한 후 | ||
| - | > # 이를 제곱하여 A의 숫자만큼 더한다 = | + | > # 이를 제곱하여 |
| > # 즉, SS를 구하는 방법. | > # 즉, SS를 구하는 방법. | ||
| > # 전체평균에서 그룹평균을 뺀 것의 제곱을 | > # 전체평균에서 그룹평균을 뺀 것의 제곱을 | ||
| > # 그룹 구성원 숫자만큼 더하는 것 | > # 그룹 구성원 숫자만큼 더하는 것 | ||
| + | > # 그리고 이들을 다시 모두 더하여 | ||
| + | > # ss.between에 저장 | ||
| > | > | ||
| - | > | + | > length(A) * ((mean.total - mean.a)^2) |
| - | > length(A)*((mean.total - mean.a)^2) | + | |
| [1] 196 | [1] 196 | ||
| - | > length(B)*((mean.total - mean.b)^2) | + | > length(B) * ((mean.total - mean.b)^2) |
| [1] 196 | [1] 196 | ||
| + | > | ||
| > ss.between <- | > ss.between <- | ||
| + | + | ||
| + | + | ||
| - | > | ||
| > ss.between | > ss.between | ||
| + | [1] 392 | ||
| + | > # df between group은 연구에 사용된 | ||
| + | > # 그룹의 숫자에서 1을 뺀 숫자 | ||
| + | > df.between <- 2 - 1 | ||
| + | > # 이 그룹 간 차이에 기인하는 분산 값은 | ||
| + | > ms.between <- ss.between / df.between | ||
| + | > ms.between | ||
| [1] 392 | [1] 392 | ||
| > | > | ||
| Line 293: | Line 499: | ||
| > ss.b <- var(B) * df.b | > ss.b <- var(B) * df.b | ||
| > ss.within <- ss.a + ss.b | > ss.within <- ss.a + ss.b | ||
| - | > | + | > df.a <- length(A)-1 |
| - | > # Now check this | + | > df.b <- length(B)-1 |
| - | > ss.total | + | |
| - | [1] 2552 | + | |
| - | > ss.between | + | |
| - | [1] 392 | + | |
| - | > ss.within | + | |
| - | [1] 2160 | + | |
| - | > ss.total == ss.between + ss.within | + | |
| - | [1] FALSE | + | |
| - | > | + | |
| - | > # 한편 df는 | + | |
| - | > # df.total | + | |
| - | > df.between <- 2-1 # 그룹숫자 - 1 | + | |
| - | > df.a <- length(A)-1 # a 구성원 | + | |
| - | > df.b <- length(B)-1 # b 구성원 | + | |
| > df.within <- df.a + df.b | > df.within <- df.a + df.b | ||
| + | > ms.within <- ss.within / df.within | ||
| > | > | ||
| - | > df.total | + | > ms.within |
| - | [1] 31 | + | [1] 72 |
| - | > df.between | + | |
| - | [1] 1 | + | |
| - | > df.within | + | |
| - | [1] 30 | + | |
| - | > df.total == df.between + df.within | + | |
| - | [1] TRUE | + | |
| > | > | ||
| - | > # 분산을 구하는 방법은 SS/df 이므로 | + | > # 여기까지 우리는 |
| - | > # 분산을 ms 라고 표기하면 우리는 | + | > # 전체분산 |
| - | > # ms.total, ms.between, ms.within을 구할 수 있다 | + | > # 그룹간분산 |
| - | > | + | > # 그룹내분산 값을 |
| - | > ms.total <- ss.total / df.total | + | > # 구한 것 |
| - | > ms.between <- ss.between / df.between | + | |
| - | > ms.within <- ss.within / df.within | + | |
| > | > | ||
| - | > # 위에서 | + | > # ms.between은 그룹의 차이때문에 생긴 |
| > # 분산으로 IV 혹은 treatment 때문에 생기는 | > # 분산으로 IV 혹은 treatment 때문에 생기는 | ||
| > # 차이에 기인하는 분산이고 | > # 차이에 기인하는 분산이고 | ||
| Line 338: | Line 523: | ||
| > # t test 때와 마찬가지로 | > # t test 때와 마찬가지로 | ||
| > # 그룹의 차이 / 랜덤 차이를 (에러 -> 분산은 에러라고도 했다) | > # 그룹의 차이 / 랜덤 차이를 (에러 -> 분산은 에러라고도 했다) | ||
| - | > # 구해볼 수 있다. | + | > # 구해볼 수 있다. |
| - | > # 이를 프린트아웃 한다 | + | |
| > | > | ||
| + | > # 즉, 그룹갑분산은 사실 = diff (between groups) | ||
| + | > # 그리고 그룹내 분산은 사실 = re | ||
| + | > # 따라서 우리는 위 둘 간의 비율을 t test와 같이 | ||
| + | > # 살펴볼 수 있다 | ||
| + | > | ||
| + | > | ||
| + | > # 이것을 f.calculated 이라고 하고 | ||
| > f.calculated <- ms.between / ms.within | > f.calculated <- ms.between / ms.within | ||
| + | > # 이 값을 출력해 본다 | ||
| > f.calculated | > f.calculated | ||
| [1] 5.444444 | [1] 5.444444 | ||
| + | > # 이 계산은 차이와 랜덤에러의 비율이 | ||
| + | > # df에 따라서 얼마나 되어야 그 차이가 | ||
| + | > # 충분히 큰 것인지를 판단하기 위해서 | ||
| + | > # 쓰인다. 여기서 df에는 두 가지 종류가 | ||
| + | > # 있다. df.between 그리고 df.within | ||
| > | > | ||
| + | > # percentage of f distribution with | ||
| + | > # df1 and df2 option | ||
| + | > # 이는 그림의 왼쪽을 나타내므로 | ||
| + | > # 차이가 점점 커지게 되는 오른쪽을 | ||
| + | > # 계산하기 위해서는 1-x를 취한다 | ||
| + | > f.calculated.pvalue <- 1-pf(f.calculated, | ||
| + | > f.calculated.pvalue | ||
| + | [1] 0.02652366 | ||
| > # 한편, | > # 한편, | ||
| > # samples t-test를) 아웃 풋은 | > # samples t-test를) 아웃 풋은 | ||
| Line 361: | Line 566: | ||
| > | > | ||
| + | > # 그리고 f 계산에서의 p value는 t test에서의 p.value와 같다 | ||
| + | > f.calculated.pvalue | ||
| + | [1] 0.02652366 | ||
| + | > t.result$p.value | ||
| + | [1] 0.02652366 | ||
| + | > | ||
| + | > # 또한 | ||
| > # 여기엣 t 값은 t.result$statistic 으로 프린트아웃할 수 있다 | > # 여기엣 t 값은 t.result$statistic 으로 프린트아웃할 수 있다 | ||
| > # 이 값이 2.33333 이었다 | > # 이 값이 2.33333 이었다 | ||
| Line 383: | Line 595: | ||
| [1] 2.333333 | [1] 2.333333 | ||
| > | > | ||
| + | > # Now check this | ||
| + | > ss.total | ||
| + | [1] 2552 | ||
| + | > ss.between | ||
| + | [1] 392 | ||
| + | > ss.within | ||
| + | [1] 2160 | ||
| + | > ss.total | ||
| + | [1] 2552 | ||
| + | > ss.between + ss.within | ||
| + | [1] 2552 | ||
| + | > | ||
| + | > # 한편 df는 | ||
| + | > # df.total | ||
| + | > df.total | ||
| + | [1] 31 | ||
| + | > df.between | ||
| + | [1] 1 | ||
| + | > df.within | ||
| + | [1] 30 | ||
| + | > df.total | ||
| + | [1] 31 | ||
| + | > df.between + df.within | ||
| + | [1] 31 | ||
| > | > | ||
| > # 한 편 | > # 한 편 | ||
| > | > | ||
| > A | > A | ||
| - | [1] 20.994218 31.148068 16.961481 27.240217 28.354539 | + | [1] 20.994218 31.148068 16.961481 27.240217 28.354539 |
| - | [7] 31.914700 23.459605 35.361796 22.182136 30.847396 15.575648 | + | [6] 38.331534 |
| - | [13] 41.264878 | + | [11] 30.847396 15.575648 41.264878 |
| + | [16] 22.527973 | ||
| > B | > B | ||
| - | [1] 12.941146 21.270062 13.235378 | + | [1] 12.941146 21.270062 13.235378 |
| - | [7] 18.276359 | + | [6] 27.231465 |
| - | [13] 25.018756 25.302096 28.941002 23.293888 | + | [11] 25.017185 19.639663 25.018756 25.302096 28.941002 |
| + | [16] 23.293888 | ||
| > comb <- stack(list(a=A, | > comb <- stack(list(a=A, | ||
| > comb | > comb | ||
| Line 473: | Line 711: | ||
| Residuals | Residuals | ||
| --- | --- | ||
| - | Signif. codes: | + | Signif. codes: |
| + | 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 | ||
| > # 위에서 F value는 5.444 | > # 위에서 F value는 5.444 | ||
| > # 그리고 전체적인 아웃풋을 보면 | > # 그리고 전체적인 아웃풋을 보면 | ||
| Line 511: | Line 750: | ||
| | | ||
| 2.333333 | 2.333333 | ||
| - | > | ||
| </ | </ | ||
c/ms/2023/schedule/week06_t-test_and_anova_note.1681254175.txt.gz · Last modified: by hkimscil
