summary_of_hypothesis_testing:code01
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| summary_of_hypothesis_testing:code01 [2025/11/30 22:10] – hkimscil | summary_of_hypothesis_testing:code01 [2025/11/30 22:51] (current) – hkimscil | ||
|---|---|---|---|
| Line 17: | Line 17: | ||
| sd.p2 <- sd(p2) | sd.p2 <- sd(p2) | ||
| - | n.s <- 36 | + | n.s <- 25 |
| se.z1 <- c(sqrt(var(p1)/ | se.z1 <- c(sqrt(var(p1)/ | ||
| se.z2 <- c(sqrt(var(p2)/ | se.z2 <- c(sqrt(var(p2)/ | ||
| Line 38: | Line 38: | ||
| plot(x.p1, y.p1, type = " | plot(x.p1, y.p1, type = " | ||
| | | ||
| - | main = "Sample means ", n.s, "from p1 and p2 (imaginary)", | + | main = paste0("sample (n = ",n.s, ") means from p1 and p2 (unknown)"), |
| xlab = " | xlab = " | ||
| lines(x.p2, y.p2, lty=2, lwd=3) | lines(x.p2, y.p2, lty=2, lwd=3) | ||
| Line 59: | Line 59: | ||
| diff <- m.treated.s-mean(p1) | diff <- m.treated.s-mean(p1) | ||
| diff/se.z1 | diff/se.z1 | ||
| - | zscore <- diff/se.z1 | + | zscore <- abs(diff/se.z1) |
| pnorm(zscore, | pnorm(zscore, | ||
| tscore <- zscore | tscore <- zscore | ||
| - | pt(tscore, df=length(treated.s)-1, lower.tail = F)*2 | + | pt(tscore, df=n.s-1, lower.tail = F)*2 |
| # usual way - using sample' | # usual way - using sample' | ||
| Line 118: | Line 118: | ||
| plot(x.p.est, | plot(x.p.est, | ||
| | | ||
| - | main = "population mean estimated | + | main = paste0(" |
| - | xlab = " | + | xlab = paste0(" |
| se1 <- c(m.treated.s-se.s, | se1 <- c(m.treated.s-se.s, | ||
| se2 <- c(m.treated.s-2*se.s, | se2 <- c(m.treated.s-2*se.s, | ||
| Line 129: | Line 129: | ||
| | | ||
| - | pt(diff/se.s, df=n.s-1, lower.tail = F) * 2 | + | tscore <- abs(diff/se.s) |
| + | pt(tscore, df=n.s-1, lower.tail = F) * 2 | ||
| t.test(treated.s, | t.test(treated.s, | ||
| + | |||
| </ | </ | ||
summary_of_hypothesis_testing/code01.1764540639.txt.gz · Last modified: by hkimscil
