[R] Correlations Table of Items when compute Cronbach's Alpha
David L Carlson
dcarlson at tamu.edu
Tue Feb 21 18:44:15 CET 2017
Actually you will need ?psych::alpha to get the help page. The correlations provided in output$item.stats are with the total score. If you want a correlation matrix for the original 4 variables you can use sweep() to invert the necessary column(s):
> cor(sweep(dat, 2, c(1, 1, 1, -1), FUN="*"), use="complete.obs")
X1 X2 X3 X4
X1 1.0000000 0.1396653 0.1916540 0.2865590
X2 0.1396653 1.0000000 0.5184912 0.2938423
X3 0.1916540 0.5184912 1.0000000 0.5037861
X4 0.2865590 0.2938423 0.5037861 1.0000000
If you use check.keys=TRUE you can extract the vector from the results:
> output <- alpha(dat, check.keys=TRUE)
Warning message:
In alpha(dat, check.keys = TRUE) :
Some items were negatively correlated with total scale and were automatically reversed.
This is indicated by a negative sign for the variable name.
> output$keys
[1] 1 1 1 -1
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Mark Sharp
Sent: Tuesday, February 21, 2017 11:14 AM
To: Steven Stoline <sstoline at gmail.com>
Cc: r-help at r-project.org
Subject: Re: [R] Correlations Table of Items when compute Cronbach's Alpha
Have you looked at the help page?
?alpha::alpha
See the section labeled Value.
Look at
output <- alpha(data, keys = c(1, 1, 1, -1))
output$r
output$r.cor
output$r.drop
R. Mark Sharp, Ph.D.
msharp at TxBiomed.org
> On Feb 21, 2017, at 9:43 AM, Steven Stoline <sstoline at gmail.com> wrote:
>
> Dear All:
>
>
> I am using *alpha(data, **check.keys=TRUE) or alpha(data, keys = c(1, 1,
> 1, -1))* to compute the Cronbach's Alpha. I am using *check.keys=TRUE*
> or *keys = c(1, 1, 1, -1) *to automatically reverse items.
>
>
> *My question is: *how can I get the correlation tables (matrix) of the
> reversed items as part of the R output.
>
>
>
> *Here is an example of the data set:*
>
>
> X1 X2 X3 X4
> 2 5 4 4
> 1 1 1 6
> 1 2 1 6
> 2 3 2 4
> 1 2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2
> 2 2 2 4
> 1 1 1 6
> 4 2 2 5
> 2 3 1 5
> 2 1 2 5
> 2 2 1 5
> 1 2 2 5
> 1 2 1 5
> 6 2 2 4
> 2 2 5 2
> 2 5 3 5
> 1 4 4 4
> 1 1 1 6
>
>
> thank you
> steve
>
> ------------------------
> Steven M. Stoline
> sstoline at gmail.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:9}}
More information about the R-help
mailing list