T Test

An illustratio of how a T Test can be performed and summarized with statsample.

References

http://en.wikipedia.org/wiki/Student%27s_t-test

In [1]:
require 'statsample'

Statsample::Analysis.store(Statsample::Test::T) do
  a   = rnorm(10)
  t_1 = Statsample::Test.t_one_sample(a,{:u=>50})
  
  summary t_1
  
  b   = rnorm(10,2)
  t_2 = Statsample::Test.t_two_samples_independent(a,b)
  
  summary t_2
end

Statsample::Analysis.run_batch
Analysis 2016-03-26 10:23:17 +0000
= Statsample::Test::T
  == One Sample T Test
    Sample mean: -0.4698 | Sample sd: 1.1807 | se : 0.3734
    Population mean: 50.0000
    t(9) = -135.1683, p=0.0000 (both tails)
    CI(95%): -51.3144 - -49.6251
  == Two Sample T Test
    Mean and standard deviation
+----------+---------+--------+----+
| Variable |  mean   |   sd   | n  |
+----------+---------+--------+----+
|          | -0.4698 | 1.1807 | 10 |
|          | 1.8296  | 0.8102 | 10 |
+----------+---------+--------+----+

    Levene test for equality of variances : F(1, 18) = 1.4575 , p = 0.2430
    T statistics
+--------------------+---------+---------+----------------+
|        Type        |    t    |   df    | p (both tails) |
+--------------------+---------+---------+----------------+
| Equal variance     | -5.0777 | 18      | 0.0001         |
| Non equal variance | -5.0777 | 15.9373 | 0.0001         |
+--------------------+---------+---------+----------------+

    Effect size
+-------+---------+
| x1-x2 | -2.2994 |
| d     | -2.4293 |
+-------+---------+