Skip to content

Instantly share code, notes, and snippets.

@JoFrhwld
Last active December 13, 2015 20:58
Show Gist options
  • Save JoFrhwld/4973557 to your computer and use it in GitHub Desktop.
Save JoFrhwld/4973557 to your computer and use it in GitHub Desktop.
# http://www.cdc.gov/nchs/data/nhsr/nhsr010.pdf
n_fem = 604
h_fem = 162.2
se_fem = 0.34
sd_fem = se_fem * sqrt(n_fem)
n_mal = 591
h_mal = 176.6
se_mal = 0.38
sd_mal = se_mal * sqrt(n_mal)
pooled_sd_height <- sqrt((n_fem*sd_fem^2 + n_mal*sd_mal^2)/(n_mal+n_fem))
(h_mal-h_fem)/pooled_sd_height
# [1] 1.635762
library(plyr)
length_mean <- ddply(length_est, .(Sex), summarise,
est1_mean = mean(est1),
est1_sd = sd(est1),
N = length(File))
length_mean
# Sex est1_mean est1_sd N
# 1 f 14.90808 1.107414 201
# 2 m 16.98004 1.354225 149
pooled_sd <- with(length_mean,
sqrt(sum((N-1)*(est1_sd^2))/sum(N))
)
abs(diff(length_mean$est1_mean)) / pooled_sd
# [1] 1.705293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment