# -------------------------------
# Data from the EUROFAMCARE sample dataset
# -------------------------------
data(efc)
# retrieve variable and value labels
varlabs <- get_var_labels(efc)
# recveive first item of COPE-index scale
start <- which(colnames(efc) == "c82cop1")
# recveive last item of COPE-index scale
end <- which(colnames(efc) == "c90cop9")
# create data frame with COPE-index scale
df <- as.data.frame(efc[, c(start:end)])
colnames(df) <- varlabs[c(start:end)]
sjt.df(reliab_test(df),
describe = FALSE,
showCommentRow = TRUE,
commentString = sprintf("Cronbach's α=%.2f",
cronb(df)))
# ---------------------------------------
# Compute PCA on Cope-Index, and perform a
# reliability check on each extracted factor.
# ---------------------------------------
factors <- sjt.pca(df)$factor.index
findex <- sort(unique(factors))
for (i in 1:length(findex)) {
rel.df <- subset(df, select = which(factors == findex[i]))
if (ncol(rel.df) >= 3) {
sjt.df(reliab_test(rel.df),
describe = FALSE,
showCommentRow = TRUE,
useViewer = FALSE,
title = "Item-Total-Statistic",
commentString = sprintf("Scale's overall Cronbach's α=%.2f",
cronb(rel.df)))
}
}
Run the code above in your browser using DataLab