卡方检验

收录时间:2018-09-30
资源分类:Matlab 工具:MATLAB 7.4 (R2007a)

卡方检验是一种用途很广的计数资料的假设检验方法。它属于非参数检验的范畴,主要是比较两个及两个以上样本率( 构成比)以及两个分类变量的关联性分析。其根本思想就是在于比较理论频数和实际频数的吻合程度或拟合优度问题。

它在分类资料统计推断中的应用,包括:两个率或两个构成比比较的卡方检验;多个率或多个构成比比较的卡方检验以及分类资料的相关分析等。

 

chi2test

Usage: [p, Q]= chi2test(x)

 

The chi-squared test.

 

Given a number of samples this function tests the hypothesis that the samples are

independent. If Q > chi2(p, nu), the hypothesis is rejected.

 

Each column represents a variables, each row a sample.

 

If you find any errors, please let me know: .

 

ARGUMENTS:

x Absolut numbers.

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]= chi2test([324, 556-324; 98, 260-98])

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

Throw two different dices to see if they have the same probability of 1 (and 2, 3, 4, 5, 6).

We don't check if they are symetrical, only if the both behave in the same way.

[p,Q] = chi2test([15,10; 7,11; 9,7; 20,15; 26,21; 19,16])

p= 0.8200

Q = 2.2059

The dices don't significantly behave differently. That is, they seem to behave in the same way.

 

HISTORY: v.1.0, first working version, 2007-08-30.

 

COPYRIGHT: (c) 2007 Peder Axensten. Use at own risk.

文件下载列表
chi2test.zip (1.85KB)  
附件内容(只显示2中的1个)
chi2test.m  
标签: 卡方检验 
更多

目前尚无评论

用户反馈   关于我们
Copyright (©) ZHIHUISHI.COM 2013 All Rights Reserved.
京ICP备14040384号