1. Experiment or Observational Study.
Is this an experiment or an observational study?
-
Experiment
-
Observational study
Solution.
This is an experiment because researchers determined which subjects would be sleep deprived.




combn function in R, from the combinat package, assuming imprvs contains the response variable values) shows the distribution of all 352,716 possible differences in group means.

indices = 1:21
allcombs = combn(21, 10)
diffs = 1:ncol(allcombs)
for (i in 1:ncol(allcombs)){
group1=imprvs[allcombs[,i]]
group2=imprvs[setdiff(indices, allcombs[,i])]
diffs[i]=mean(group1)-mean(group2)
}
hist(diffs)
abline(v=15.92, col=2)
# approx. run time: 1 min
I = 10000 # use upper case
diff = 0 # initializes the vector
for (i in 1:I){ # the loop for I iterations
rerandom = sample(improvement) # mixes up response values
boxplot(rerandom~condition, horizontal=TRUE)
diff[i] = mean(rerandom[1:10]) - mean(rerandom[11:21]) # match up the explanatory variable group sizes
}
diff and compute the empirical p-value as before.
hist(diff); abline(v=15.92, col=2) # adds vertical line
sum(diff >= 15.92)/I # p-value