Skip to content

cronbachs alpha - score.items(psych) vs reliability(Rcmdr)

6 messages · achristoffersen, John Fox, William Revelle +3 more

#
Dear all,

I like the way the Rcmdr package computes reliability. E.g

reliability(cov(d[,c("q1", "q2", "q3", "q4", "q5", "q6")],
use="complete.obs"))

will not only give me the alpha score, but also for each variable,
alpha.score if deleted. However - when writing scripts it's very tiresome to
load the whole Rcmdr GUI just for this purpose. So I'm looking for an
another package that delivers the same feature.

the score.items function in the psych package i find is too complicated (it
requires a keys vector) and it doesn't report the "alpha if deleted" score.

What have I missed when googling for an alternative?

Thx in advance

Andreas
#
Dear Andreas,

I don't know whether there's another comparable function, but reliability()
from the Rcmdr package is very simple; here it is printed out (as you could
have done simply by typing its name -- I added the assignment arrow):

reliability <-
function (S) 
{
    reliab <- function(S, R) {
        k <- dim(S)[1]
        ones <- rep(1, k)
        v <- as.vector(ones %*% S %*% ones)
        alpha <- (k/(k - 1)) * (1 - (1/v) * sum(diag(S)))
        rbar <- mean(R[lower.tri(R)])
        std.alpha <- k * rbar/(1 + (k - 1) * rbar)
        c(alpha = alpha, std.alpha = std.alpha)
    }
    result <- list()
    if ((!is.numeric(S)) || !is.matrix(S) || (nrow(S) != ncol(S)) || 
        any(abs(S - t(S)) > max(abs(S)) * 1e-10) || nrow(S) < 
        2) 
        stop(gettextRcmdr("argument must be a square, symmetric, numeric
covariance matrix"))
    k <- dim(S)[1]
    s <- sqrt(diag(S))
    R <- S/(s %o% s)
    rel <- reliab(S, R)
    result$alpha <- rel[1]
    result$st.alpha <- rel[2]
    if (k < 3) {
        warning(gettextRcmdr("there are fewer than 3 items in the scale"))
        return(invisible(NULL))
    }
    rel <- matrix(0, k, 3)
    for (i in 1:k) {
        rel[i, c(1, 2)] <- reliab(S[-i, -i], R[-i, -i])
        a <- rep(0, k)
        b <- rep(1, k)
        a[i] <- 1
        b[i] <- 0
        cov <- a %*% S %*% b
        var <- b %*% S %*% b
        rel[i, 3] <- cov/(sqrt(var * S[i, i]))
    }
    rownames(rel) <- rownames(S)
    colnames(rel) <- c("Alpha", "Std.Alpha", "r(item, total)")
    result$rel.matrix <- rel
    class(result) <- "reliability"
    result
}

As an alternative to loading the package, you could just put the function
definition in a file -- editing out the calls to gettextRcmdr, which are for
translation of the error messages -- and source() the file when you want to
use it. You'll probably also want the print method (obtained by
Rcmdr:::print.reliability):

print.reliability <-
function (x, digits = 4, ...) 
{
    cat(paste("Alpha reliability = ", round(x$alpha, digits), 
        "\n"))
    cat(paste("Standardized alpha = ", round(x$st.alpha, digits), 
        "\n"))
    cat("\nReliability deleting each item in turn:\n")
    print(round(x$rel.matrix, digits))
    invisible(x)
}

I hope this helps,
 John

------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox
On
to
(it
score.
http://www.R-project.org/posting-guide.html
#
Dear Andreas,
   I agree with John that it is straight forward to just include your 
own function to do what both Rcmdr and psych do for finding alpha.

psych does not have any function to do the alpha if deleted option, 
mainly because I think alpha is not a particularly good (although 
very popular) estimate of reliability and it is even worse when using 
the delete one item option.  The recent set of papers in 
Psychometrika by Sitjsma, Bentler, Green and me (the latter three 
commenting on the target paper by Sitjsma) discussing alpha 
summarizes the problems.

In terms of ease of use you might look at the guttman function in 
psych.  Given a data matrix or correlation matrix, with all items 
keyed in the same direction, it will find  6 different estimates of 
reliability (finding standardized alpha).  You might also want to 
examine  the score.items and cluster.cor functions.

The keys vector in score.items, cluster.cor, and score.alpha is meant 
to allow you to score multiple scales at the same time (as well as 
reverse key some items) and then find the item-whole correlation as 
well as interscale correlations.

Following your suggestion, I will eventually add the drop out one 
item option to score.alpha.

Bill
At 7:47 PM -0500 2/3/09, John Fox wrote:

  
    
  
#
The item.total command in the "multilevel" package will give you what
you want.

--Chris
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY  13790
cryanatbinghamtondotedu
PGP public keys available at http://home.stny.rr.com/ryancw/

"If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea."  [Antoine de St. Exupery]
achristoffersen wrote:
#
The alpha.Summary() function in MiscPsycho does this. Here is an example
Below is what alpha *would be* if the item were removed 
 
   Item     alpha
1     1 0.5776860
2     2 0.5620276
3     3 0.5336340
4     4 0.5561580
5     5 0.5852708
6     6 0.5875561
7     7 0.5258138
8     8 0.5324561
9     9 0.5285075
10   10 0.5898000
#
You can run a function from a package by doing something like:
This will load the package in the background, but not run the gui and other things.  So you can use the function(s) that you want without running everything like when you do library(Rcmdr).

Hope this helps,