## These code lines illustrate Cronbach's alpha coefficient calculation
## for interval-valued, Likert-type, and visual analogue scales responses
## Some trivial cronbach() examples
## Cronbach's alpha index for interval-valued scale responses stored
## in a matrix with the inf/sup-characterization variable by variable
## using Bertoluzza's distance with Lebesgue measure (theta = 1/3)
data1 <- matrix(c(1, 2.6, 1.5, 3, 3.8, 6, 4, 7), 2, 4)
cronbach(data1, theta = 1/3)
## Cronbach's alpha index for interval-valued scale responses stored
## in a data.frame with the mid/spr-characterization saving all the
## mid-points and then all the spreads using rho2 distance (theta = 1)
data2 <- data.frame(mids1 = c(2, 3),
mids2 = c(4, 5),
sprs1 = c(1, 2),
sprs2 = c(2, 4))
cronbach(data2, type = 4)
## Cronbach's alpha coefficient for Likert-type
## scale responses stored in a matrix
data3 <- matrix(c(1, 3, 4, 7), 2, 2)
cronbach(data3, ivs = FALSE)
## Cronbach's alpha coefficient for visual analogue
## scale responses stored in a data.frame
data4 <- data.frame(item1 = c(1.5, 2.8),
item2 = c(3.9, 6.2))
cronbach(data4, ivs = FALSE)
## Real-life data example
## Load the interval-valued data
data(lackinfo, package = "IntervalQuestionStat")
## Calculate Cronbach's alpha coefficient for interval-valued responses
cronbach(lackinfo[, 3:12])
## Convert interval-valued responses into their corresponding equivalent
## Likert-type answers and then calculate Cronbach's alpha coefficient
likert <- ivs2likert(IntervalMatrix(lackinfo[, 3:12]))
cronbach(likert, ivs = FALSE)
## Analogously, interval-valued responses are transformed into their
## corresponding equivalent visual analogue scale answers and
## Cronbach's alpha coefficient is then computed
vas <- ivs2vas(IntervalMatrix(lackinfo[, 3:12]))
cronbach(vas, ivs = FALSE)
Run the code above in your browser using DataLab