summary_of_hypothesis_testing:code01
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| summary_of_hypothesis_testing:code01 [2025/11/30 15:29] – created 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 | + | main = paste0("sample (n = ",n.s, " |
| 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 111: | Line 111: | ||
| m.p2 | m.p2 | ||
| + | x.p.est <- seq(m.treated.s-5*se.s, | ||
| + | | ||
| + | | ||
| + | y.p.est <- dnorm(x.p.est, | ||
| + | |||
| + | plot(x.p.est, | ||
| + | | ||
| + | main = paste0(" | ||
| + | xlab = paste0(" | ||
| + | se1 <- c(m.treated.s-se.s, | ||
| + | se2 <- c(m.treated.s-2*se.s, | ||
| + | se3 <- c(m.treated.s-3*se.s, | ||
| + | abline(v=c(m.treated.s, | ||
| + | | ||
| + | ' | ||
| + | ' | ||
| + | | ||
| - | 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.1764516543.txt.gz · Last modified: by hkimscil
