Skip to content

Instantly share code, notes, and snippets.

@bwiernik
Created June 16, 2020 21:19
Show Gist options
  • Save bwiernik/168393bf6d12c9a47a1a62a7a71eb199 to your computer and use it in GitHub Desktop.
Save bwiernik/168393bf6d12c9a47a1a62a7a71eb199 to your computer and use it in GitHub Desktop.
stratified alpha R function
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