[R] Code for Coefficent (Cronbach's) Alpha
MagillB at usa.redcross.org
Mon Jul 17 21:13:22 CEST 2000
I am trying to teach myself to use and program R (How else do you do it?
lol) Anyway, I wrote a piece of code to compute coefficent alpha for a
scale. As I am neither a statistician nor a programmer, I wanted people's
feedback. The code appears to work (Win 95 with R 1.0.1) and I have
verified my result with SPSS and it was correct (much to my astonishment!).
Nonetheless, I am sure there are better ways to do things than I did it as I
have limited documentation and was reading as I programmed. Much of the
process was trial and error for me (oops, error!, how can I fix that?). So,
as an opportunity to learn, I thought I would send the code to the list for
comments. Would be interested in hearing if there are potential problems
with my code or easier ways of doing things. Please be nice, I know much of
the "programming" here is probably naive.
z.x<-scale(x, center = TRUE, scale = TRUE)
for (i in 1:n.items) score.total<-score.total + x[,i]
for (i in 1:n.items) var.items<-var.items + var(x[,i])
for (i in 1:n.items) z.score.total<-z.score.total + z.x[,i]
for (i in 1:n.items) z.var.items<-z.var.items + var(z.x[,i])
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