Created
June 16, 2020 21:19
-
-
Save bwiernik/60fe5ac7a3ef2448c7652ebce2890b9d to your computer and use it in GitHub Desktop.
stratified alpha R function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alpha_stratified <- function(x, a, na.rm = TRUE) { | |
v <- diag(var(x, na.rm = na.rm)) | |
vt <- sum(var(x, na.rm = na.rm)) | |
ev <- sum((1 - a) * v) | |
return(list(strat.alpha = c(1 - ev/vt), scores = rowMeans(x, na.rm = TRUE))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment