Created
December 6, 2013 05:23
-
-
Save anonymous/7818995 to your computer and use it in GitHub Desktop.
Odds比と適合度検定(カイ2乗検定)の計算
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
summary : | |
odds比を計算 | |
detail : | |
与えられた群Aと、(全体-群A)との発生率との比を計算 | |
args : | |
total --全体の数 | |
incidence --全体の発生数 | |
a_total --群Aの全体数 | |
a_incidence --群Aの発生数 | |
-} | |
odd_ratio total incidence a_total a_incidence = | |
(a_incidence / a_total) / (incidence_exclude_a / total_exclude_a) | |
where | |
total_exclude_a = total - a_total | |
incidence_exclude_a = incidence - a_incidence | |
{- | |
summary : | |
適合度検定(カイ2乗検定)の計算 | |
detail : | |
与えられた群Aと、(全体-群A)との発生数から適合度検定を実施 | |
args : | |
total --全体の数 | |
incidence --全体の発生数 | |
a_total --群Aの全体数 | |
a_incidence --群Aの発生数 | |
-} | |
chisq total incidence a_total a_incidence = | |
chisq' a_incidence estimate_incidence | |
+ chisq' a_no_incidence estimate_no_incidence | |
where | |
rate = (incidence - a_incidence) / (total - a_total) --(全体-群A)の発生率 | |
estimate_incidence = a_total * rate --a群の予想発生数 | |
estimate_no_incidence = a_total * (1 - rate) --a群の予想非発生数 | |
a_no_incidence = a_total - a_incidence --a群の非発生数 | |
chisq' actual estimate = (estimate - actual)**2 / estimate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment