Skip to content

Commit

Permalink
Merge 66614f0 into 946021a
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrusdn committed Dec 30, 2013
2 parents 946021a + 66614f0 commit 5bf1ff6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions statsmodels/stats/inter_rater.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,43 @@ def to_table(data, bins=None):

return tt[0], bins_

def cronbach_alpha(itemscores):
'''Compute Cronbach's Alpha
Parameters
----------
itemscores : array_like
n*p array or dataframe, n subjects and p items
Returns
-------
Calpha : float
To interpret the output the rule of George, D., & Mallery, P. (2003)
can be used
> .9 (Excellent),
> .8 (Good),
> .7 (Acceptable),
> .6 (Questionable),
> .5(Poor), and < .5 (Unacceptable)
Notes
-----
Cronbach's Alpha is the most commonly used measure of internal consistency.
One problem might be Cronbach's Alpha is not robust against missing data.
References
----------
Wikipedia
'''

itemscores = np.asarray(itemscores)
itemscores = itemscores[~np.isnan(itemscores).any(axis = 1)]
itemvars = itemscores.var(axis = 1, ddof = 1)
tscores = itemscores.sum(axis = 0)
nitems = len(itemscores)
calpha = nitems / (nitems - 1.) * (1 - itemvars.sum() / tscores.var(ddof = 1))

return calpha

def fleiss_kappa(table):
'''Fleiss' kappa multi-rater agreement measure
Expand Down

0 comments on commit 5bf1ff6

Please sign in to comment.