#We compute the worst split-half reliabilities on a correlation matrix.
# \donttest{
#Load the correlation matrix Bechtoldt from the psych
#package (see ?Bechtoldt for more information).
if (requireNamespace("psych", quietly = TRUE)) {
data("Bechtoldt", package = "psych")
}
R <- Bechtoldt
### RUN HC-SVD FOR HIERARCHICAL VARIABLE CLUSTERING
#Compute HC-SVD (with average linkage).
hcsvd.obj <- hcsvd(R)
#The object of type hclust with corresponding dendrogram can be obtained
#directly from hcsvd(...):
hc.div <- hcsvd.obj$hclust
plot(hc.div, axes = FALSE, ylab = "", main = "Revelle's Beta Splits")
### COMPUTE REVELLE'S BETA FOR ALL IDENTIFIED SPLITS
#Compute Revelle's beta
betas <- hc.beta(R = R)
#Alternatively, you can submit the object obtained from hcsvd(). Thus,
#the hiearchy needs not to be computed again using hcsvd().
betas <- hc.beta(R = R, splits = hcsvd.obj)
#Visualize the splits, e.g., as
splits <- sapply(betas, `[[`, "split")
beta.values <- sapply(betas, `[[`, "beta")
plot(splits, beta.values,
type = "b",
xlab = "Split",
ylab = "Revelle's Beta",
main = "Revelle's Beta Across Splits",
pch = 19)
#Visualize the ratio of Revelle's beta and Cronbach's alpha
beta.alpha <- sapply(betas, `[[`, "beta.alpha")
plot(splits, beta.values,
type = "b",
xlab = "Split",
ylab = "Beta/Alpha",
main = "Ratio of Beta and Alpha Across Splits",
pch = 19)
### COMPUTE REVELLE'S BETA FOR THE FIRST IDENTIFIED SPLIT
#The first split can be identified using bd.approx()
#This is computationally faster, as only the first split
#is identified
hc.beta(R = R, splits = bd.approx(R))
# }
Run the code above in your browser using DataLab