{"id":2094,"date":"2022-01-08T17:10:31","date_gmt":"2022-01-08T09:10:31","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=2094"},"modified":"2022-01-08T17:10:31","modified_gmt":"2022-01-08T09:10:31","slug":"%e5%8d%a1%e6%96%b9%e6%a3%80%e9%aa%8c","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=2094","title":{"rendered":"\u5361\u65b9\u68c0\u9a8c"},"content":{"rendered":"\n<p>chisq.test()\u51fd\u6570\u5bf9\u4e8c\u7ef4\u8868\u7684\u884c\u5217\u53d8\u91cf\u8fdb\u884c\u5361\u65b9\u68c0\u9a8c<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4f7f\u7528vcd\u5305\u4e2dArthritis\u6570\u636e\u96c6<\/h1>\n\n\n\n<p>library(vcd)<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u751f\u6210\u5217\u8054\u8868\u683c\u5f0f<\/h1>\n\n\n\n<p>mytable &lt;- xtabs(~Treatment+Improved,data = Arthritis)<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><kbd><span class=\"has-inline-color has-vivid-red-color\"><strong>\u5361\u65b9\u68c0\u9a8c<\/strong><\/span><\/kbd><\/h1>\n\n\n\n<p>chisq.test(mytable)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Pearson's Chi-squared test<\/code><\/pre>\n\n\n\n<p>data: mytable<br>X-squared = 13.055, df = 2, p-value = 0.001463<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">p\u503c\u5c0f\u4e8e0.05,\u8bf4\u660e\u6cbb\u7597\u60c5\u51b5\u548c\u6539\u5584\u60c5\u51b5\u4e0d\u72ec\u7acb\u3002<\/h5>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Fisher\u7cbe\u786e\u68c0\u9a8c<\/strong><br>fisher.test()\u51fd\u6570<br>\u683c\u5f0ffisher.test(mytable),mytable\u662f\u4e00\u4e2a\u4e8c\u7ef4\u5217\u8054\u8868<\/h3>\n\n\n\n<p>library(vcd)<br>mytable &lt;- xtabs(~Treatment+Improved,data = Arthritis)<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u8c03\u7528fisher.test()\u51fd\u6570<\/h1>\n\n\n\n<p>fisher.test(mytable)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Fisher's Exact Test for Count\nData<\/code><\/pre>\n\n\n\n<p>data: mytable<br>p-value = 0.001393<br>alternative hypothesis: two.sided<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">P\u5c0f\u4e8e0.05\uff0c\u4e24\u8005\u4e4b\u95f4\u4e0d\u72ec\u7acb<\/h5>\n\n\n\n<p><strong><em>Cochran-Mantel-Haenszel\u68c0\u9a8c<\/em><\/strong><br>\u4e3a\u4e24\u4e2a\u4e8c\u5206\u7c7b\u53d8\u91cf\u8fdb\u884c\u5206\u5c42\u5361\u65b9\u68c0\u9a8c\u3002<br>mantelhaen.test()<\/p>\n\n\n\n<p>mytable &lt;- xtabs(~Treatment+Improved+Sex,data = Arthritis)<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u8c03\u7528mantelhaen.test()\u51fd\u6570<\/h1>\n\n\n\n<p>mantelhaen.test(mytable)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Cochran-Mantel-Haenszel test<\/code><\/pre>\n\n\n\n<p>data: mytable<br>Cochran-Mantel-Haenszel M^2 =<br>14.632, df = 2, p-value =<br>0.0006647<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u7ed3\u679c\u8868\u660e\uff0c\u60a3\u8005\u63a5\u53d7\u7684\u6cbb\u7597\u4e0e\u5f97\u5230\u7684\u6539\u5584\u5728\u6027\u522b\u7684\u6bcf\u4e00\u6c34\u5e73\u4e0b\u5e76\u4e0d\u72ec\u7acb<\/h6>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"has-inline-color has-vivid-purple-color\">\u5176\u4ed6\u5b9e\u4f8b<\/span><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u56db\u4e2a\u8868\u5361\u65b9\u68c0\u9a8c--\u6570\u636e\u6846\u6570\u636e\u683c\u5f0f\na &lt;- c(9,2)\nb &lt;- c(4,9)\ny &lt;- data.frame(a,b)\nchisq.test( y) \nchisq.test(y,correct = F)  #\u65e0\u8fde\u7eed\u6027\u8f83\u6b63\u8ba1\u7b97\u7ed3\u679c\nchisq.test(y)$observed  #\u89c2\u5bdf\u503c\uff08\u5b9e\u9645\u6570\uff09\nchisq.test(y)$expected  #\u671f\u671b\u503c\uff08\u7406\u8bba\u6570\uff09\nprint('=======================')\nfisher.test(y)\n#\u56db\u4e2a\u8868\u5361\u65b9\u68c0\u9a8c---\u77e9\u9635\u6570\u636e\u683c\u5f0f\nz &lt;- matrix(c(12, 5, 7, 7), ncol = 2)\nchisq.test(z) \nprint('======================')\n#\u884cX\u5217\u8868\u5361\u65b9\u68c0\u9a8c\nx &lt;- matrix(c(50,48,18,72,105,10,7,23), ncol = 2)\nchisq.test(x)\nprint('======================')<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>chisq.test()\u51fd\u6570\u5bf9\u4e8c\u7ef4\u8868\u7684\u884c\u5217\u53d8\u91cf\u8fdb\u884c\u5361\u65b9\u68c0\u9a8c \u4f7f\u7528vcd\u5305\u4e2dArt <span class=\"readmore\"><a href=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=2094\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,5],"tags":[],"class_list":["post-2094","post","type-post","status-publish","format-standard","hentry","category-r","category-statistics"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2094","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2094"}],"version-history":[{"count":0,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2094\/revisions"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2094"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}