Skip to content

Instantly share code, notes, and snippets.

@ceshine
Last active Jan 7, 2016
Embed
What would you like to do?
ANOVA of Observations v.s. ANOVO of Bootstrapped Statistics
n.samples = 100
series.A = rnorm(n.samples, 0, 2)
series.B = rnorm(n.samples, 0.1, 2)
bundle = data.frame(y=c(series.A, series.B), x=c(rep(0, n.samples), rep(1, n.samples)))
summary(aov(y ~ factor(x), data=bundle))
resampleTotal <- function(x){
sum(sample(x, length(x), replace=T))
}
n.resamples = 100
series.A.sum.resamples = rep(0, n.resamples)
series.B.sum.resamples = rep(0, n.resamples)
for(i in 1:n.resamples){
series.A.sum.resamples[i] = resampleTotal(series.A)
series.B.sum.resamples[i] = resampleTotal(series.B)
}
bundle.resample = data.frame(y=c(series.A.sum.resamples, series.B.sum.resamples), x=c(rep(0, n.resamples), rep(1, n.resamples)))
summary(aov(y ~ factor(x), data=bundle.resample))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment