Tetrachoric Correlation¶

Tetrachoric correlation in statsample requires installation of the statsample-bivariate-extension gem. This gem extends the Statsample::Bivariate class with useful algorithms for polychoric and tetrachoric correlation.

Statsample will automatically detect presence of polychoric/tetrachoric algorithms so there is no need to explicitly require the gem.

In this example we'll see how tetrachoric correlation can be performed using statsampl

In [1]:
require 'statsample'

Statsample::Analysis.store(Statsample::Bivariate::Tetrachoric) do
a = 40
b = 10
c = 20
d = 30
# The 'tetrachoric' shorthand calls the Statsample::Bivariate::Tetrachoric class internally
summary tetrachoric(a,b,c,d)
end

Statsample::Analysis.run_batch

Analysis 2015-06-04 16:06:58 +0530
= Statsample::Bivariate::Tetrachoric
== Tetrachoric correlation
Contingence Table
+-----+-----+-----+-----+
|     | Y=0 | Y=1 |  T  |
+-----+-----+-----+-----+
| X=0 | 40  | 10  | 50  |
| X=1 | 20  | 30  | 50  |
+-----+-----+-----+-----+
| T   | 60  | 40  | 100 |
+-----+-----+-----+-----+

r: 0.607
SE: 0.115
Threshold X: 0.000
Threshold Y: 0.253