Be the first to rate this file! 79 downloads (last 30 days) File Size: 76.62 KB File ID: #16178

chi2bintest

by Peder Axensten

 

30 Aug 2007 (Updated 30 Aug 2007)

Code covered by BSD License  

The chi-squared binary test.

Download Now | Watch this File

File Information
Description

Usage: [p, Q]= chi2bintest(x, n)
 
The chi-squared binary test.
 
Given a number of samples with a binary outcome ("is or is not something"),
this function tests the hypothesis that the samples are independent.
If Q > chi2(p, nu), the hypothesis is rejected.
 
If x is a vector, each item is the result of a sample.
n must be a scalar (same total for all samples) or a vector of the same length as x.
 
If x is a matrix, each row is the result of a sample. Each column is an independent
sample series. n must be a scalar (same total for all samples) or
a vector of the same length as the number of samples in x (same totals for all sample
series) or a matrix of the same size as x.
 
If you find any errors, please let me know: .
 
ARGUMENTS:
x Relative frequencies of the outcome, if 0<=x<=1. Absolut number count, if integer x>=0.
n Number of tries.
p The prob ability value, calculated from Q.
Q The resulting Q-value.
 
EXAMPLE 1
In region A, 324 of 556 cows were red, whereas in region B 98 of 260 were red.
[p, Q]= chi2bintest([324; 98], [556; 260])
p= 4.2073e-08
Q= 30.0515
With an error risk of about 4e-08, we can claim that the samples are independent.
 
EXAMPLE 2
In three regions, reindeers were cheched for four various deseases.
p= chi2bintest([28,39,8,4782; 17,7,5,903; 21,14,6,2322], [15996; 10127; 12476])
p = 0.9869 0.0007 0.9973 0
It seems that the first and third deseases are region independent, whereas the others
have regional dependencies (are independent to each other).
 
HISTORY: v.1.0, first working version, 2007-08-30.
 
COPYRIGHT: (c) 2007 Peder Axensten. Use at own risk.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Could probably be used even with very early versions of Matlab.
Zip File Content  
Other Files __MACOSX/chi2bintest/._.DS_Store,
chi2bintest/.DS_Store,
chi2bintest/chi2bintest.m,
chi2bintest/documentation.pdf,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Peder Axensten 22 Oct 2008 09:24:57
probability Peder Axensten 22 Oct 2008 09:24:57
chisquared test Peder Axensten 22 Oct 2008 09:24:57
chisquared Peder Axensten 22 Oct 2008 09:24:57
chi2 Peder Axensten 22 Oct 2008 09:24:57
binary Peder Axensten 22 Oct 2008 09:24:57
test Peder Axensten 22 Oct 2008 09:24:57
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com