Last active
January 25, 2018 07:24
-
-
Save kamermanpr/aaa598485b6e990017375359ff5f4533 to your computer and use it in GitHub Desktop.
Wald confidence interval of robustlmm::rlmer beta coefficients
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
# Wald confidence interval of robustlmm::rlmer beta coefficients | |
# Adapted from code provided Ben Bolker on StackExchange: https://stats.stackexchange.com/questions/233800/how-can-i-get-confidence-intervals-for-fixed-effects-using-the-rlmer-function-r | |
confint.rlmerMod <- function(object, level = 0.95) { | |
# Extract beta coefficients | |
beta <- fixef(object) | |
# Extract names of coefficients | |
parm <- names(beta) | |
# Extract standard errors for the coefficients | |
se <- sqrt(diag(vcov(object))) | |
# Set level of confidence interval | |
z <- qnorm((1 + level) / 2) | |
# Calculate CI | |
ctab <- cbind(beta - (z * se), | |
beta + (z * se)) | |
# label column names | |
colnames(ctab) <- c(paste(100 * ((1 - level) / 2), '%'), | |
paste(100 * ((1 + level) / 2), '%')) | |
# Output | |
return(ctab[parm, ]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment