[R] Item Analysis and Cronbach's Alpha (Code Attached)

Mark Myatt mark at myatt.demon.co.uk
Tue Mar 27 11:39:21 CEST 2001


Magill, Brett <MagillB at usa.redcross.org> writes:

>A short function I wrote for the purpose of evaluating scales made up of a
>number of questionnaire items.  It provides Cronbach's Alpha, both
>unstandardized and based on standardized items.  It also provides item
>statistics which include item-total correlations (corrected) and
>item-removed alpha.  Thought some of you might find it useful.  I would also
>appreciate any programming tips or suggestions for improving the function as
>I am still relatively new to R and statistical programming in general.

I haven't used the function but one comment is that R functions often
return a structure rather than printed output. This allows the use of
print() and summary() functions to display different levels of detail as
well as allowing the function's output to be paced in an object for
further manipulation. This is usually done by returning a list with a
class. If you return the list with class "alpha":

        class(TOTAL.STATISTICS) <- "alpha"
        return(TOTAL.STATISTICS)

You can then create a function print.alpha() which will be called
automatically whenever you run alpha() without assigning it's output to
another object, when you type the name of an "alpha" object, or use the
print() function with an "alpha" object. You could also create a
function alpha.summary() which will be called whenever you use the
summary() function with an "alpha" object.

The print() function usually return a summary and the summary() function
returns more detail (I've never worked that out!).

There is a brief tutorial on this sort of thing in my notes on R at:

        http://www.myatt.demon.co.uk

Mark

--
Mark Myatt


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list