Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example for chi-square homogeneity test #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/chisquare_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/ruby
$:.unshift(File.dirname(__FILE__)+'/../lib')
require 'statsample'

Statsample::Analysis.store(Statsample::Test::ChiSquare) do
# Collect the two vectors with the categorical data (raw number of occurences) into one matrix. Here
#--------------------------------------------
#| category | observation 1 | observation 2 |
#|------------------------------------------|
#| A | 100 | 20 |
#| B | 50 | 70 |
#| C | 30 | 100 |
#|------------------------------------------|
#
m=Matrix[[100, 50, 30],[20, 70, 100]]
x_2=Statsample::Test.chi_square(m)
# after the test is done, look at the p-value.
puts x_2.probability
end

if __FILE__==$0
Statsample::Analysis.run_batch
end