Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid r code for t groups. Minor correction needed. #50

Open
TobyHFerguson opened this issue Jun 26, 2017 · 1 comment
Open

Invalid r code for t groups. Minor correction needed. #50

TobyHFerguson opened this issue Jun 26, 2017 · 1 comment

Comments

@TobyHFerguson
Copy link

Under the heading Mistakenly treating the sleep data as grouped the R code uses the value of x_1 and x_2 - these should be g_1 and g_2 respectively. Thus the code should read:

n1 <- length(g1); n2 <- length(g2)
sp <- sqrt( ((n1 - 1) * sd(g1)^2 + (n2-1) * sd(g2)^2) / (n1 + n2-2))
md <- mean(g2) - mean(g1)
semd <- sp * sqrt(1 / n1 + 1/n2)
rbind(
  md + c(-1, 1) * qt(.975, n1 + n2 - 2) * semd,  
  t.test(g2, g1, paired = FALSE, var.equal = TRUE)$conf,
  t.test(g2, g1, paired = TRUE)$conf
)
@benthecoder
Copy link

I noticed this too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants