{"id":169,"date":"2025-06-05T10:57:49","date_gmt":"2025-06-05T01:57:49","guid":{"rendered":"https:\/\/best-biostatistics.com\/toukei-er\/?p=169"},"modified":"2025-06-10T00:42:59","modified_gmt":"2025-06-09T15:42:59","slug":"r-script-for-mcnemar-test-sample-size-calculation","status":"publish","type":"post","link":"https:\/\/best-biostatistics.com\/toukei-er\/entry\/r-script-for-mcnemar-test-sample-size-calculation\/","title":{"rendered":"R \u3067\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306b\u5fc5\u8981\u306a\u30b5\u30f3\u30d7\u30eb\u6570\u3092\u8a08\u7b97\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u300c\u6cbb\u7642\u524d\u5f8c\u306e\u52b9\u679c\u300d\u300c\u65bd\u7b56\u306b\u3088\u308b\u610f\u8b58\u306e\u5909\u5316\u300d\u306a\u3069\u3001\u540c\u3058\u5bfe\u8c61\u8005\u306e2\u3064\u306e\u6642\u70b9\u3067\u306e\u5909\u5316\u3092\u77e5\u308a\u305f\u3044\u3068\u304d\u3001<strong>\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a<\/strong>\u304c\u5f79\u7acb\u3064\u3002\u3053\u306e\u691c\u5b9a\u306f2\u5024\u30c7\u30fc\u30bf\uff08\u306f\u3044\/\u3044\u3044\u3048\u306a\u3069\uff09\u306e\u5909\u5316\u3092\u5206\u6790\u3059\u308b\u306e\u306b\u6700\u9069\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u57fa\u672c\u304b\u3089\u3001R\u3092\u4f7f\u3063\u305f\u8a08\u7b97\u4f8b\u3001\u3055\u3089\u306b\u306f\u9069\u5207\u306a<strong>\u30b5\u30f3\u30d7\u30eb\u6570<\/strong>\u306e\u898b\u7a4d\u3082\u308a\u65b9\u307e\u3067\u3001\u521d\u5fc3\u8005\u306b\u3082\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002R\u3067\u624b\u8efd\u306b\u7d71\u8a08\u5206\u6790\u3092\u59cb\u3081\u3001\u30c7\u30fc\u30bf\u306e\u771f\u5b9f\u3092\u660e\u3089\u304b\u306b\u3057\u3088\u3046\uff01<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u3068\u306f<\/h2>\n\n\n\n<p>\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306f\u3001\u3042\u308b\u51e6\u7f6e\u306e\u524d\u3068\u5f8c\u3067\u3001\u540c\u3058\u5bfe\u8c61\u8005\u306e\u4e8c\u5024\u306e\u5fdc\u7b54\u304c\u3069\u306e\u3088\u3046\u306b\u5909\u5316\u3057\u305f\u304b\u3092\u5206\u6790\u3059\u308b\u306e\u306b\u7528\u3044\u308b\u7d71\u8a08\u624b\u6cd5\u3060\u3002<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u65b0\u3057\u3044\u85ac\u306e\u670d\u7528\u524d\u5f8c\u3067\u75c5\u6c17\u306e\u6709\u7121\u304c\u3069\u3046\u5909\u5316\u3057\u305f\u304b\u3001\u3042\u308b\u3044\u306f\u5e83\u544a\u3092\u898b\u305f\u524d\u5f8c\u3067\u5546\u54c1\u8cfc\u5165\u610f\u6b32\u304c\u3069\u3046\u5909\u5316\u3057\u305f\u304b\u306a\u3069\u3092\u8a55\u4fa1\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u3069\u3093\u306a\u3068\u304d\u306b\u4f7f\u3046\u304b\u306e\u5177\u4f53\u4f8b<\/h3>\n\n\n\n<p><br>\u3053\u306e\u691c\u5b9a\u306f\u3001\u5909\u5316\u306e\u65b9\u5411\u6027\u3084\u3001\u5909\u5316\u3057\u305f\u4eba\u3005\u306e\u5272\u5408\u304c\u6709\u610f\u3067\u3042\u308b\u304b\u3092\u5224\u65ad\u3059\u308b\u306e\u306b\u9069\u3057\u3066\u304a\u308a\u3001\u5bfe\u5fdc\u306e\u3042\u308b\u4e8c\u9805\u30c7\u30fc\u30bf\u306e\u5206\u6790\u306b\u7279\u5316\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001\u51e6\u7f6e\u524d\u3068\u5f8c\u3067\u300c\u306f\u3044\u300d\u304b\u3089\u300c\u3044\u3044\u3048\u300d\u306b\u5909\u308f\u3063\u305f\u4eba\u6570\u3068\u3001\u300c\u3044\u3044\u3048\u300d\u304b\u3089\u300c\u306f\u3044\u300d\u306b\u5909\u308f\u3063\u305f\u4eba\u6570\u306e\u9593\u306b\u6709\u610f\u306a\u5dee\u304c\u3042\u308b\u304b\u3092\u30ab\u30a4\u4e8c\u4e57\u5206\u5e03\u306b\u57fa\u3065\u3044\u3066\u8a55\u4fa1\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u5909\u5316\u304c\u306a\u304b\u3063\u305f\u30b1\u30fc\u30b9\u306f\u8003\u616e\u305b\u305a\u3001\u5909\u5316\u304c\u3042\u3063\u305f\u30b1\u30fc\u30b9\u306e\u307f\u306b\u7740\u76ee\u3059\u308b\u70b9\u304c\u7279\u5fb4\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f8b\uff1a\u6cbb\u7642\u306b\u3088\u308b\u75be\u60a3\u306e\u91cd\u75c7\u5ea6\u306e\u5909\u5316<\/h3>\n\n\n\n<p>\u3042\u308b\u75be\u60a3\u306e\u60a3\u8005\u3055\u3093\u306b\u5bfe\u3057\u3001\u7279\u5b9a\u306e\u6cbb\u7642\u3092\u884c\u3063\u305f\u7d50\u679c\u3001\u91cd\u75c7\u5ea6\u304c\u3069\u306e\u3088\u3046\u306b\u5909\u5316\u3057\u305f\u304b\u3092\u8a55\u4fa1\u3059\u308b\u30b1\u30fc\u30b9\u3092\u8003\u3048\u3088\u3046\u3002\u3053\u3053\u3067\u306f\u3001\u91cd\u75c7\u5ea6\u3092\u300c\u8efd\u5ea6\u300d<strong>\u3068<\/strong>\u300c\u91cd\u5ea6\u300d\u306e2\u3064\u306e\u30ab\u30c6\u30b4\u30ea\u306b\u5206\u3051\u3066\u6e2c\u5b9a\u3059\u308b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><\/td><td>\u6cbb\u7642\u5f8c\uff1a\u8efd\u5ea6<\/td><td>\u6cbb\u7642\u5f8c\uff1a\u91cd\u5ea6<\/td><\/tr><tr><td>\u6cbb\u7642\u524d\uff1a\u8efd\u5ea6<\/td><td>a<\/td><td>b<\/td><\/tr><tr><td>\u6cbb\u7642\u524d\uff1a\u91cd\u5ea6<\/td><td>c<\/td><td>d<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>a<\/strong>: \u6cbb\u7642\u524d\u3082\u6cbb\u7642\u5f8c\u3082<strong>\u8efd\u5ea6<\/strong>\u3060\u3063\u305f\u60a3\u8005\u6570 <\/li>\n\n\n\n<li><strong>b<\/strong>: \u6cbb\u7642\u524d\u306f<strong>\u8efd\u5ea6<\/strong>\u3060\u3063\u305f\u304c\u3001\u6cbb\u7642\u5f8c\u306f<strong>\u91cd\u5ea6<\/strong>\u306b\u306a\u3063\u305f\u60a3\u8005\u6570\uff08\u60aa\u5316\uff09<\/li>\n\n\n\n<li><strong>c<\/strong>: \u6cbb\u7642\u524d\u306f<strong>\u91cd\u5ea6<\/strong>\u3060\u3063\u305f\u304c\u3001\u6cbb\u7642\u5f8c\u306f<strong>\u8efd\u5ea6<\/strong>\u306b\u306a\u3063\u305f\u60a3\u8005\u6570\uff08\u6539\u5584\uff09 <\/li>\n\n\n\n<li><strong>d<\/strong>: \u6cbb\u7642\u524d\u3082\u6cbb\u7642\u5f8c\u3082<strong>\u91cd\u5ea6<\/strong>\u3060\u3063\u305f\u60a3\u8005\u6570<\/li>\n<\/ul>\n\n\n\n<p>\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306f\u7279\u306b\u300c\u5909\u5316\u304c\u3042\u3063\u305f\u300d\u60a3\u8005\u3001\u3059\u306a\u308f\u3061<code>b<\/code>\uff08\u60aa\u5316\uff09\u3068<code>c<\/code>\uff08\u6539\u5584\uff09\u306e\u30bb\u30eb\u306b\u6ce8\u76ee\u3057\u3001\u6cbb\u7642\u306b\u3088\u3063\u3066\u300c\u6539\u5584\u3057\u305f\u300d\u60a3\u8005\uff08c\uff09\u3068\u300c\u60aa\u5316\u3057\u305f\u300d\u60a3\u8005\uff08b\uff09\u306e\u5272\u5408\u306b\u6709\u610f\u306a\u5dee\u304c\u3042\u308b\u304b\u3092\u691c\u5b9a\u3059\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. \u30c7\u30fc\u30bf\u306e\u6e96\u5099\n# \u4eee\u306e\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\n# \u4f8b\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7d50\u679c\u304c\u5f97\u3089\u308c\u305f\u3068\u3057\u307e\u3059\u3002\n#   - \u6cbb\u7642\u524d\u3082\u6cbb\u7642\u5f8c\u3082\u8efd\u5ea6: 65\u4eba (a)\n#   - \u6cbb\u7642\u524d\u306f\u8efd\u5ea6\u3060\u3063\u305f\u304c\u6cbb\u7642\u5f8c\u306f\u91cd\u5ea6: 15\u4eba (b)\n#   - \u6cbb\u7642\u524d\u306f\u91cd\u5ea6\u3060\u3063\u305f\u304c\u6cbb\u7642\u5f8c\u306f\u8efd\u5ea6: 40\u4eba (c)\n#   - \u6cbb\u7642\u524d\u3082\u6cbb\u7642\u5f8c\u3082\u91cd\u5ea6: 30\u4eba (d)\n# \u75c7\u4f8b\u6570\uff1a150\u4eba\uff08= 65 + 15 + 40 + 30\uff09\n\n# 2x2\u306e\u5206\u5272\u8868\u3092matrix\u5f62\u5f0f\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002\n# \u884c\u3092\u300c\u6cbb\u7642\u524d\u300d\u3001\u5217\u3092\u300c\u6cbb\u7642\u5f8c\u300d\u3068\u3057\u307e\u3059\u3002\n\ndata_matrix_severity &lt;- matrix(c(\n  65, 15,  # \u6cbb\u7642\u524d \u8efd\u5ea6 (\u6cbb\u7642\u5f8c \u8efd\u5ea6, \u6cbb\u7642\u5f8c \u91cd\u5ea6)\n  40, 30   # \u6cbb\u7642\u524d \u91cd\u5ea6 (\u6cbb\u7642\u5f8c \u8efd\u5ea6, \u6cbb\u7642\u5f8c \u91cd\u5ea6)\n), nrow = 2, byrow = TRUE)\n\n# \u884c\u540d\u3068\u5217\u540d\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3001\u7d50\u679c\u304c\u5206\u304b\u308a\u3084\u3059\u304f\u306a\u308a\u307e\u3059\nrownames(data_matrix_severity) &lt;- c(\"\u6cbb\u7642\u524d: \u8efd\u5ea6\", \"\u6cbb\u7642\u524d: \u91cd\u5ea6\")\ncolnames(data_matrix_severity) &lt;- c(\"\u6cbb\u7642\u5f8c: \u8efd\u5ea6\", \"\u6cbb\u7642\u5f8c: \u91cd\u5ea6\")\n\nprint(\"\u75be\u60a3\u91cd\u75c7\u5ea6\u5909\u5316\u306e\u5206\u5272\u8868:\")\nprint(data_matrix_severity)\n\n# 2. \u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u5b9f\u884c\n# correct = TRUE (\u30c7\u30d5\u30a9\u30eb\u30c8) \u3067\u9023\u7d9a\u6027\u306e\u88dc\u6b63\u3092\u884c\u3044\u307e\u3059\u3002\n\nresult_mcnemar_severity &lt;- mcnemar.test(data_matrix_severity, correct = TRUE)\n\n# \u7d50\u679c\u306e\u8868\u793a\nprint(\"\\n\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u7d50\u679c (\u91cd\u75c7\u5ea6\u306e\u5909\u5316):\")\nprint(result_mcnemar_severity)\n\n# 3. \u7d50\u679c\u306e\u89e3\u91c8\n# p-value\u306b\u6ce8\u76ee\u3057\u307e\u3059\u3002\n# \u3053\u306e\u4f8b\u3067\u306f\u3001\u6cbb\u7642\u524d\u306f\u91cd\u5ea6\u3060\u3063\u305f\u304c\u6cbb\u7642\u5f8c\u306b\u8efd\u5ea6\u306b\u306a\u3063\u305f\u60a3\u8005 (c=40) \u304c\u3001\n# \u6cbb\u7642\u524d\u306f\u8efd\u5ea6\u3060\u3063\u305f\u304c\u6cbb\u7642\u5f8c\u306b\u91cd\u5ea6\u306b\u306a\u3063\u305f\u60a3\u8005 (b=15) \u3088\u308a\u3082\u591a\u3044\u3053\u3068\u3092\u793a\u5506\u3057\u3066\u3044\u307e\u3059\u3002\n# \u3082\u3057p-value\u304c\u6709\u610f\u6c34\u6e96\uff08\u4f8b\u3048\u30700.05\uff09\u3092\u4e0b\u56de\u308c\u3070\u3001\u3053\u306e\u5dee\u306f\u7d71\u8a08\u7684\u306b\u6709\u610f\u3067\u3042\u308b\u3068\u5224\u65ad\u3067\u304d\u3001\n# \u6cbb\u7642\u306b\u3088\u3063\u3066\u91cd\u75c7\u5ea6\u304c\u6709\u610f\u306b\u6539\u5584\u3057\u305f\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/code><\/pre>\n\n\n\n<p>\u5206\u5272\u8868\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3002<\/p>\n\n\n\n<p>\u8efd\u5ea6\u304b\u3089\u91cd\u5ea6(b) \u306f\u300115\u4eba\/150 \u4eba=10%<\/p>\n\n\n\n<p>\u91cd\u5ea6\u304b\u3089\u8efd\u5ea6(c) \u306f\u300140\u4eba\/150 \u4eba=27%<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> print(\"\u75be\u60a3\u91cd\u75c7\u5ea6\u5909\u5316\u306e\u5206\u5272\u8868:\")\n&#91;1] \"\u75be\u60a3\u91cd\u75c7\u5ea6\u5909\u5316\u306e\u5206\u5272\u8868:\"\n> print(data_matrix_severity)\n             \u6cbb\u7642\u5f8c: \u8efd\u5ea6 \u6cbb\u7642\u5f8c: \u91cd\u5ea6\n\u6cbb\u7642\u524d: \u8efd\u5ea6           65           15\n\u6cbb\u7642\u524d: \u91cd\u5ea6           40           30<\/code><\/pre>\n\n\n\n<p>\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3001\u6709\u610f\u6c34\u6e96\u3092 0.05 \u3068\u3059\u308b\u3068\u3001P \u5024\u304c 0.05 \u3092\u4e0b\u56de\u308a\u3001\u6cbb\u7642\u524d\u3068\u6cbb\u7642\u5f8c\u306b\u306f\u5dee\u304c\u306a\u3044\u3068\u3059\u308b\u5e30\u7121\u4eee\u8aac\u306f\u68c4\u5374\u3055\u308c\u3001\u6709\u610f\u306b\u6539\u5584\u3057\u305f\u3068\u8a00\u3048\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> print(result_mcnemar_severity)\n\n        McNemar's Chi-squared test with continuity correction\n\ndata:  data_matrix_severity\nMcNemar's chi-squared = 10.473, df = 1, p-value = 0.001211<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306b\u5fc5\u8981\u306a\u30b5\u30f3\u30d7\u30eb\u6570\u8a08\u7b97<\/h2>\n\n\n\n<p>\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u8a08\u7b97\u306f\u3001\u4ed6\u306e\u591a\u304f\u306e\u7d71\u8a08\u691c\u5b9a\u3068\u540c\u69d8\u306b\u3001\u3044\u304f\u3064\u304b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4e8b\u524d\u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\u7279\u306b\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u5834\u5408\u3001discordant pairs\uff08\u4e0d\u4e00\u81f4\u30da\u30a2\uff09\u306e\u5272\u5408\u304c\u91cd\u8981\u306a\u8981\u7d20\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u8a08\u7b97\u306b\u5fc5\u8981\u306a\u60c5\u5831<\/h3>\n\n\n\n<p><strong>\u6709\u610f\u6c34\u6e96 (Alpha, \u03b1)<\/strong>: \u30bf\u30a4\u30d7I\u30a8\u30e9\u30fc\uff08\u5e30\u7121\u4eee\u8aac\u304c\u771f\u3067\u3042\u308b\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u68c4\u5374\u3057\u3066\u3057\u307e\u3046\u8aa4\u308a\uff09\u3092\u8a31\u5bb9\u3059\u308b\u78ba\u7387\u3002\u4e00\u822c\u7684\u306b0.05\uff085%\uff09\u304c\u7528\u3044\u3089\u308c\u308b\u3002<\/p>\n\n\n\n<p><strong>\u691c\u51fa\u529b (Power, 1\u2212\u03b2)<\/strong>: \u30bf\u30a4\u30d7II\u30a8\u30e9\u30fc\uff08\u5e30\u7121\u4eee\u8aac\u304c\u507d\u3067\u3042\u308b\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u53d7\u5bb9\u3057\u3066\u3057\u307e\u3046\u8aa4\u308a\uff09\u3092\u907f\u3051\u308b\u78ba\u7387\u3002\u901a\u5e380.80\uff0880%\uff09\u307e\u305f\u306f0.90\uff0890%\uff09\u304c\u8a2d\u5b9a\u3055\u308c\u308b\u3002<\/p>\n\n\n\n<p><strong>\u52b9\u679c\u91cf (Effect Size)<\/strong>: \u671f\u5f85\u3055\u308c\u308b\u6cbb\u7642\u52b9\u679c\u306e\u5927\u304d\u3055\u3002\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306b\u304a\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e2\u3064\u306e\u4e0d\u4e00\u81f4\u30da\u30a2\u306e\u5272\u5408\u304c\u7279\u306b\u91cd\u8981\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u03c001\u200b<\/strong>: \u6cbb\u7642\u524d\u306f\u300c\u306a\u3057\u300d\uff08\u4f8b\uff1a\u91cd\u5ea6\uff09\u3060\u304c\u3001\u6cbb\u7642\u5f8c\u306f\u300c\u3042\u308a\u300d\uff08\u4f8b\uff1a\u8efd\u5ea6\uff09\u306b\u306a\u308b\u78ba\u7387 (\u30bb\u30eb <code>c<\/code> \u306e\u5272\u5408)\u3002\u6539\u5584\u306e\u65b9\u5411\u6027<\/li>\n\n\n\n<li><strong>\u03c010\u200b<\/strong>: \u6cbb\u7642\u524d\u306f\u300c\u3042\u308a\u300d\uff08\u4f8b\uff1a\u8efd\u5ea6\uff09\u3060\u304c\u3001\u6cbb\u7642\u5f8c\u306f\u300c\u306a\u3057\u300d\uff08\u4f8b\uff1a\u91cd\u5ea6\uff09\u306b\u306a\u308b\u78ba\u7387 (\u30bb\u30eb <code>b<\/code> \u306e\u5272\u5408)\u3002\u60aa\u5316\u306e\u65b9\u5411\u6027<\/li>\n\n\n\n<li>\u3053\u308c\u3089\u306e\u5272\u5408\u306f\u3001\u5148\u884c\u7814\u7a76\u3084\u30d1\u30a4\u30ed\u30c3\u30c8\u30b9\u30bf\u30c7\u30a3\u3001\u307e\u305f\u306f\u81e8\u5e8a\u7684\u306a\u7d4c\u9a13\u306b\u57fa\u3065\u3044\u3066\u63a8\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u5e30\u7121\u4eee\u8aac\u3068\u5bfe\u7acb\u4eee\u8aac<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5e30\u7121\u4eee\u8aac (H0\u200b): \u03c001\u200b=\u03c010\u200b \uff08\u5909\u5316\u306e\u65b9\u5411\u6027\u3001\u3064\u307e\u308a\u3001\u6539\u5584\u307e\u305f\u306f\u60aa\u5316\u306b\u5dee\u304c\u306a\u3044\uff09<\/li>\n\n\n\n<li>\u5bfe\u7acb\u4eee\u8aac (H1\u200b): \u03c001\u200b\u2260\u03c010\u200b \uff08\u5909\u5316\u306e\u65b9\u5411\u6027\u3001\u3064\u307e\u308a\u3001\u6539\u5584\u307e\u305f\u306f\u60aa\u5316\u306b\u5dee\u304c\u3042\u308b\uff09<\/li>\n\n\n\n<li>\u7247\u5074\u691c\u5b9a\u304b\u4e21\u5074\u691c\u5b9a\u304b\u3082\u8003\u616e\u3059\u308b\u304c\u3001\u4e00\u822c\u7684\u306b\u306f\u4e21\u5074\u691c\u5b9a\u304c\u7528\u3044\u3089\u308c\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u8a08\u7b97\u306e\u57fa\u672c\u7684\u306a\u8003\u3048\u65b9<\/h3>\n\n\n\n<p>\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306f\u3001\u4e0d\u4e00\u81f4\u30da\u30a2\uff08b\u3068c\uff09\u306e\u6570\u306b\u7740\u76ee\u3059\u308b\u3002\u3053\u306e\u4e0d\u4e00\u81f4\u30da\u30a2\u306e\u7dcf\u6570 (b+c) \u304c\u3042\u308b\u7a0b\u5ea6\u5927\u304d\u3044\u5834\u5408\u306b\u30ab\u30a4\u4e8c\u4e57\u8fd1\u4f3c\u304c\u6210\u308a\u7acb\u3064\u3002\u5e30\u7121\u4eee\u8aac\u306e\u4e0b\u3067\u306f\u3001b\u3068c\u306f\u7b49\u3057\u3044\u4e8c\u9805\u5206\u5e03\u306b\u5f93\u3046\u3068\u8003\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">R\u3067\u306e\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u8a08\u7b97<\/h3>\n\n\n\n<p>\u8a2d\u5b9a\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6709\u610f\u6c34\u6e96 (\u03b1)<\/strong>: 0.05 (\u4e21\u5074\u691c\u5b9a)<\/li>\n\n\n\n<li><strong>\u691c\u51fa\u529b (1\u2212\u03b2)<\/strong>: 0.80<\/li>\n\n\n\n<li><strong>\u6cbb\u7642\u524d\u91cd\u5ea6\u304b\u3089\u6cbb\u7642\u5f8c\u8efd\u5ea6\u3078\u306e\u6539\u5584\u306e\u5272\u5408 (\u03c001\u200b)<\/strong>: 0.27 (\u5168\u88ab\u9a13\u8005\u6570\u306b\u5bfe\u3059\u308b\u5272\u5408)<\/li>\n\n\n\n<li><strong>\u6cbb\u7642\u524d\u8efd\u5ea6\u304b\u3089\u6cbb\u7642\u5f8c\u91cd\u5ea6\u3078\u306e\u60aa\u5316\u306e\u5272\u5408 (\u03c010\u200b)<\/strong>: 0.10 (\u5168\u88ab\u9a13\u8005\u6570\u306b\u5bfe\u3059\u308b\u5272\u5408)<\/li>\n<\/ul>\n\n\n\n<p><code>exact2x2<\/code> \u30d1\u30c3\u30b1\u30fc\u30b8\u306e <code>powerPaired2x2()<\/code> \u95a2\u6570\u3092\u4f7f\u3063\u305f\u4f8b\u3092\u793a\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># McNemar\u691c\u5b9a\u306e\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u3092\u76f4\u63a5\u8a08\u7b97\u3059\u308b\u30ab\u30b9\u30bf\u30e0\u95a2\u6570\n# \u3053\u308c\u306fMiettinen (1968) \u306e\u6f38\u8fd1\u8fd1\u4f3c\u306b\u57fa\u3065\u304f\u4e00\u822c\u7684\u306a\u5f0f\u3067\u3059\u3002\n\ncalculate_mcnemar_sample_size &lt;- function(p01, p10, alpha = 0.05, power = 0.80, two.sided = TRUE) {\n    # p01: \u6cbb\u7642\u524d\u304c\u9670\u6027\u3067\u6cbb\u7642\u5f8c\u304c\u967d\u6027\u306e\u5272\u5408 (c\u306e\u5272\u5408)\n    # p10: \u6cbb\u7642\u524d\u304c\u967d\u6027\u3067\u6cbb\u7642\u5f8c\u304c\u9670\u6027\u306e\u5272\u5408 (b\u306e\u5272\u5408)\n\n    # z\u5024\n    z_alpha &lt;- qnorm(1 - alpha \/ ifelse(two.sided, 2, 1))\n    z_beta &lt;- qnorm(power)\n\n    # \u4e0d\u4e00\u81f4\u30da\u30a2\u306e\u7dcf\u78ba\u7387\n    p_discordant &lt;- p01 + p10\n\n    # \u4e0d\u4e00\u81f4\u30da\u30a2\u306e\u5dee\u306e\u78ba\u7387\n    p_diff &lt;- abs(p01 - p10)\n\n    # \u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u8a08\u7b97\u5f0f\n    # Miettinen (1968) \u306e\u8fd1\u4f3c\u5f0f\n    N_miettinen = ((z_alpha * sqrt(p_discordant) + z_beta * sqrt(p_discordant - p_diff^2\/p_discordant))^2) \/ p_diff^2\n\n    return(ceiling(N_miettinen)) # \u5207\u308a\u4e0a\u3052\n}<\/code><\/pre>\n\n\n\n<p>\u8a08\u7b97\u4f8b\u3092\u793a\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8a08\u7b97\u4f8b\n# \u6cbb\u7642\u524d\u91cd\u5ea6 -> \u6cbb\u7642\u5f8c\u8efd\u5ea6 (\u6539\u5584) \u306e\u5272\u5408 = 0.27 (c\u306e\u5272\u5408)\n# \u6cbb\u7642\u524d\u8efd\u5ea6 -> \u6cbb\u7642\u5f8c\u91cd\u5ea6 (\u60aa\u5316) \u306e\u5272\u5408 = 0.10 (b\u306e\u5272\u5408)\n# \u3053\u3053\u3067\u306e\u5272\u5408\u306f\u3001\u7dcf\u88ab\u9a13\u8005\u6570\u306b\u5bfe\u3059\u308b\u5272\u5408\u3067\u3059\u3002\n# \u3064\u307e\u308a\u3001150\u4eba\u4e2d40\u4eba\u304c\u6539\u5584\u300115\u4eba\u304c\u60aa\u5316\u3059\u308b\u3001\u3068\u3044\u3063\u305f\u4eee\u5b9a\u3067\u3059\u3002\n\nrequired_n &lt;- calculate_mcnemar_sample_size(p01 = 0.27, p10 = 0.10, alpha = 0.05, power = 0.80)\nprint(paste(\"\u5fc5\u8981\u306a\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba (\u30da\u30a2\u6570):\", required_n))<\/code><\/pre>\n\n\n\n<p>Miettinen \u306e\u5f0f\u3067\u8a08\u7b97\u3059\u308b\u3068\u300194 \u30da\u30a2\u5fc5\u8981\u3068\u8fd4\u3063\u3066\u304f\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> print(paste(\"\u5fc5\u8981\u306a\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba (\u30da\u30a2\u6570):\", required_n))\n&#91;1] \"\u5fc5\u8981\u306a\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba (\u30da\u30a2\u6570): 94\"<\/code><\/pre>\n\n\n\n<p>\u6700\u7d42\u7684\u306b\u306f\u3001\u8131\u843d\u7387\u3092\u8003\u616e\u3059\u308b\u3002\u81e8\u5e8a\u7814\u7a76\u3067\u306f\u3001\u60a3\u8005\u306e\u9014\u4e2d\u306e\u8131\u843d\u304c\u8d77\u3053\u308a\u3048\u308b\u3002\u8a08\u7b97\u3055\u308c\u305f\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u306b\u3001\u4e88\u60f3\u3055\u308c\u308b\u8131\u843d\u7387\uff08\u4f8b\uff1a10%\uff09\u3092\u8003\u616e\u3057\u3066\u4e0a\u4e57\u305b\u3059\u308b\u3053\u3068\u304c\u4e00\u822c\u7684\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<div id=\"biost-925113566\" class=\"biost- biost-entity-placement\"><p style=\"text-align: center;\"><span style=\"font-size: 20px;\"><strong><a href=\"https:\/\/best-biostatistics.com\/kmhl\">\uff1e\uff1e\u3082\u3046\u7d71\u8a08\u3067\u60a9\u3080\u306e\u306f\u7d42\u308f\u308a\u306b\u3057\u307e\u305b\u3093\u304b\uff1f\u00a0<\/a><\/strong><\/span><\/p>\r\n<a href=\"https:\/\/best-biostatistics.com\/kmhl\"><img class=\"aligncenter wp-image-2794 size-full\" src=\"https:\/\/best-biostatistics.com\/wp\/wp-content\/uploads\/2023\/11\/bn_r_03.png\" alt=\"\" width=\"500\" height=\"327\" \/><\/a>\r\n<p style=\"text-align: center;\"><span style=\"color: #ff0000; font-size: 20px;\"><strong><span class=\"marker2\">\u21911\u4e07\u4eba\u4ee5\u4e0a\u306e\u533b\u7642\u5f93\u4e8b\u8005\u304c\u8cfc\u8aad\u4e2d<\/span><\/strong><\/span><\/p><\/div><h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u8a08\u7b97\u306f\u3001\u7279\u306b\u6cbb\u7642\u306b\u3088\u308b\u60aa\u5316 (\u03c010\u200b)<strong>\u3068<\/strong>\u6539\u5584 (\u03c001\u200b)\u306e\u5272\u5408\u3092\u4e8b\u524d\u306b\u3069\u308c\u3060\u3051\u6b63\u78ba\u306b\u898b\u7a4d\u3082\u308b\u304b\u306b\u304b\u304b\u3063\u3066\u3044\u308b\u3002\u3053\u308c\u3089\u306e\u5024\u3092\u73fe\u5b9f\u7684\u306b\u8a2d\u5b9a\u3057\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u8907\u6570\u306e\u30b7\u30ca\u30ea\u30aa\u3067\u8a08\u7b97\u3092\u884c\u3046\u3053\u3068\u3067\u3001\u9069\u5207\u306a\u30b5\u30f3\u30d7\u30eb\u30b5\u30a4\u30ba\u3092\u6c7a\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u300c\u6cbb\u7642\u524d\u5f8c\u306e\u52b9\u679c\u300d\u300c\u65bd\u7b56\u306b\u3088\u308b\u610f\u8b58\u306e\u5909\u5316\u300d\u306a\u3069\u3001\u540c\u3058\u5bfe\u8c61\u8005\u306e2\u3064\u306e\u6642\u70b9\u3067\u306e\u5909\u5316\u3092\u77e5\u308a\u305f\u3044\u3068\u304d\u3001\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u304c\u5f79\u7acb\u3064\u3002\u3053\u306e\u691c\u5b9a\u306f2\u5024\u30c7\u30fc\u30bf\uff08\u306f\u3044\/\u3044\u3044\u3048\u306a\u3069\uff09\u306e\u5909\u5316\u3092\u5206\u6790\u3059\u308b\u306e\u306b\u6700\u9069\u3002 \u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u30de\u30af\u30cd\u30de\u30fc\u691c\u5b9a\u306e\u57fa\u672c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,16,120],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","hentry","category-r","category-16","category-120"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/comments?post=169"}],"version-history":[{"count":4,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":3940,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/169\/revisions\/3940"}],"wp:attachment":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}