Skip to content

Instantly share code, notes, and snippets.

@sachsmc
Created August 20, 2014 14:28
Show Gist options
  • Save sachsmc/fda939cb70ff7ac5d5b6 to your computer and use it in GitHub Desktop.
Save sachsmc/fda939cb70ff7ac5d5b6 to your computer and use it in GitHub Desktop.
frequentist approach
## frequentist approach for comparison
freq_leaveout <- function(formula) {
leftout <- sapply(1:n.trials, function(i){
fit.biv <- lm(formula, data = hat.test[-i, ])
predict(fit.biv, newdata = hat.test)[i]
})
full <- predict(lm(formula, data = hat.test))
list(leftout = leftout, full = full)
}
freq.summary <- list(a = freq_leaveout(T2.hat ~ T1.a.hat),
b = freq_leaveout(T2.hat ~ T1.b.hat),
biv = freq_leaveout(T2.hat ~ T1.a.hat + T1.b.hat))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment