{"id":4283,"date":"2025-07-20T09:53:32","date_gmt":"2025-07-20T00:53:32","guid":{"rendered":"https:\/\/best-biostatistics.com\/toukei-er\/?p=4283"},"modified":"2025-07-20T09:53:34","modified_gmt":"2025-07-20T00:53:34","slug":"regression-line-testing-and-confidence-intervals-in-r-calculation-without-the-lm-function","status":"publish","type":"post","link":"https:\/\/best-biostatistics.com\/toukei-er\/entry\/regression-line-testing-and-confidence-intervals-in-r-calculation-without-the-lm-function\/","title":{"rendered":"R\u3067\u56de\u5e30\u76f4\u7dda\u306e\u691c\u5b9a\u3068\u4fe1\u983c\u533a\u9593\uff1alm\u95a2\u6570\u3092\u4f7f\u308f\u305a\u306b\u8a08\u7b97\u3059\u308b"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5358\u56de\u5e30\u5206\u6790\u3067\u306f\u3001\u76ee\u7684\u5909\u6570\u3068\u8aac\u660e\u5909\u6570\u306e\u9593\u306b\u76f4\u7dda\u7684\u306a\u95a2\u4fc2\u304c\u3042\u308b\u304b\u3092\u8abf\u3079\u308b\u3002R\u306e<code>lm<\/code>\u95a2\u6570\u3092\u4f7f\u3048\u3070\u7c21\u5358\u306b\u5206\u6790\u3067\u304d\u308b\u304c\u3001\u305d\u306e\u88cf\u5074\u306b\u3042\u308b\u8a08\u7b97\u30ed\u30b8\u30c3\u30af\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3082\u91cd\u8981\u3060\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001<code>lm<\/code>\u95a2\u6570\u306b\u983c\u3089\u305a\u306b\u56de\u5e30\u76f4\u7dda\u306e\u4e3b\u8981\u306a\u8981\u7d20\u3001\u3064\u307e\u308a<strong>\u56de\u5e30\u4fc2\u6570<\/strong>\u306e\u63a8\u5b9a\u3001\u305d\u306e<strong>\u691c\u5b9a<\/strong>\u3001\u305d\u3057\u3066<strong>95%\u4fe1\u983c\u533a\u9593<\/strong>\u306e\u8a08\u7b97\u3092R\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u5b9f\u88c5\u3059\u308b\u3002\u3055\u3089\u306b\u3001\u3053\u308c\u3089\u306e\u624b\u52d5\u8a08\u7b97\u306e\u7d50\u679c\u3092<code>lm<\/code>\u95a2\u6570\u306e\u51fa\u529b\u3068\u6bd4\u8f03\u3057\u3001\u305d\u306e\u7cbe\u5ea6\u3092\u78ba\u8a8d\u3057\u3066\u3044\u304f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">\u5358\u56de\u5e30\u76f4\u7dda\u306e\u57fa\u672c\u30e2\u30c7\u30eb<\/h2>\n\n\n\n<p>\u5358\u56de\u5e30\u5206\u6790\u306e\u30e2\u30c7\u30eb\u306f\u3001\u4ee5\u4e0b\u306b\u793a\u3059\u76f4\u7dda\u306e\u65b9\u7a0b\u5f0f\u3067\u8868\u3055\u308c\u308b\u3002<\/p>\n\n\n\n<p>$$Y_i = \\beta_0 + \\beta_1 X_i + \\epsilon_i$$<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u3001<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>$Y_i$: \u76ee\u7684\u5909\u6570\uff08\u5f93\u5c5e\u5909\u6570\uff09<\/li>\n\n\n\n<li>$X_i$: \u8aac\u660e\u5909\u6570\uff08\u72ec\u7acb\u5909\u6570\uff09<\/li>\n\n\n\n<li>$\\beta_0$: \u5207\u7247\u3002$X=0$\u306e\u3068\u304d\u306e$Y$\u306e\u671f\u5f85\u5024\u3002<\/li>\n\n\n\n<li>$\\beta_1$: \u56de\u5e30\u4fc2\u6570\u3002$X$\u304c1\u5358\u4f4d\u5897\u52a0\u3057\u305f\u3068\u304d\u306e$Y$\u306e\u5909\u5316\u91cf\u3092\u793a\u3057\u3001\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u3092\u8868\u3059\u3002<\/li>\n\n\n\n<li>$\\epsilon_i$: \u8aa4\u5dee\u9805\u3002\u89b3\u6e2c\u5024\u3068\u56de\u5e30\u76f4\u7dda\u3068\u306e\u305a\u308c\u3067\u3001\u5e73\u57470\u3001\u5206\u6563$\\sigma^2$\u306e\u6b63\u898f\u5206\u5e03\u306b\u5f93\u3046\u3068\u4eee\u5b9a\u3055\u308c\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u306e\u30e2\u30c7\u30eb\u304b\u3089\u3001\u79c1\u305f\u3061\u306f\u30c7\u30fc\u30bf\u306e\u30d1\u30bf\u30fc\u30f3\u306b\u6700\u3082\u30d5\u30a3\u30c3\u30c8\u3059\u308b<strong>\u56de\u5e30\u76f4\u7dda<\/strong>\u3092\u898b\u3064\u3051\u3001\u305d\u306e\u50be\u304d\uff08$\\beta_1$\uff09\u304c\u7d71\u8a08\u7684\u306b\u610f\u5473\u306e\u3042\u308b\u3082\u306e\u304b\uff08\u3064\u307e\u308a0\u3067\u306f\u306a\u3044\u304b\uff09\u3092\u5224\u65ad\u3057\u3001\u305d\u306e\u4fe1\u983c\u3067\u304d\u308b\u7bc4\u56f2\uff08\u4fe1\u983c\u533a\u9593\uff09\u3092\u6c42\u3081\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u3068\u5207\u7247\u306e\u63a8\u5b9a\uff08\u6700\u5c0f\u4e8c\u4e57\u6cd5\uff09<\/h2>\n\n\n\n<p>\u56de\u5e30\u76f4\u7dda\u3092\u30c7\u30fc\u30bf\u306b\u6700\u3082\u3088\u304f\u30d5\u30a3\u30c3\u30c8\u3055\u305b\u308b\u306b\u306f\u3001<strong>\u6700\u5c0f\u4e8c\u4e57\u6cd5<\/strong>\u3092\u7528\u3044\u308b\u3002\u3053\u308c\u306f\u3001\u5b9f\u969b\u306e$Y$\u306e\u5024\u3068\u56de\u5e30\u76f4\u7dda\u304b\u3089\u4e88\u6e2c\u3055\u308c\u308b$\\hat{Y}$\u306e\u5024\u3068\u306e\u5dee\uff08\u6b8b\u5dee\uff09\u306e\u4e8c\u4e57\u548c\u304c\u6700\u5c0f\u306b\u306a\u308b\u3088\u3046\u306b\u3001$\\beta_0$\u3068$\\beta_1$\u3092\u63a8\u5b9a\u3059\u308b\u65b9\u6cd5\u3060\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u56de\u5e30\u4fc2\u6570($\\beta_1$)\u306e\u63a8\u5b9a\u5024 $\\hat{\\beta}_1$<\/strong><\/li>\n<\/ul>\n\n\n\n<p>$$\\hat{\\beta}_1 = \\frac{\\sum_{i=1}^{n}(X_i &#8211; \\bar{X})(Y_i &#8211; \\bar{Y})}{\\sum_{i=1}^{n}(X_i &#8211; \\bar{X})^2}$$<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5207\u7247($\\beta_0$)\u306e\u63a8\u5b9a\u5024 $\\hat{\\beta}_0$<\/strong><\/li>\n<\/ul>\n\n\n\n<p>$$\\hat{\\beta}_0 = \\bar{Y} &#8211; \\hat{\\beta}_1 \\bar{X}$$<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u3001$\\bar{X}$\u3068$\\bar{Y}$\u306f\u305d\u308c\u305e\u308c$X$\u3068$Y$\u306e\u5e73\u5747\u5024\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<div id=\"biost-3797984693\" 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\">\u56de\u5e30\u4fc2\u6570\u306b\u5bfe\u3059\u308b\u6a19\u6e96\u8aa4\u5dee\u306e\u8a08\u7b97<\/h2>\n\n\n\n<p>\u56de\u5e30\u4fc2\u6570\u306e\u63a8\u5b9a\u5024\u306e\u7cbe\u5ea6\u3092\u793a\u3059\u306e\u304c<strong>\u6a19\u6e96\u8aa4\u5dee<\/strong>\u3060\u3002\u3053\u306e\u5024\u306f\u3001\u63a8\u5b9a\u3055\u308c\u305f\u56de\u5e30\u4fc2\u6570\u306e\u3070\u3089\u3064\u304d\u306e\u5ea6\u5408\u3044\u3092\u8868\u3057\u3001\u691c\u5b9a\u3084\u4fe1\u983c\u533a\u9593\u306e\u8a08\u7b97\u306b\u4e0d\u53ef\u6b20\u3068\u306a\u308b\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6b8b\u5dee\u5e73\u65b9\u548c (RSS)<\/strong><\/li>\n<\/ul>\n\n\n\n<p>$$RSS = \\sum_{i=1}^{n}(Y_i &#8211; \\hat{Y}_i)^2 = \\sum_{i=1}^{n}(Y_i &#8211; (\\hat{\\beta}_0 + \\hat{\\beta}_1 X_i))^2$$<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6b8b\u5dee\u5206\u6563\u306e\u63a8\u5b9a\u5024 ($\\hat{\\sigma}^2$)<\/strong><\/li>\n<\/ul>\n\n\n\n<p>$$\\hat{\\sigma}^2 = \\frac{RSS}{n-2}$$<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u56de\u5e30\u4fc2\u6570($\\hat{\\beta}_1$)\u306e\u6a19\u6e96\u8aa4\u5dee $SE(\\hat{\\beta}_1)$<\/strong><\/li>\n<\/ul>\n\n\n\n<p>$$SE(\\hat{\\beta}_1) = \\sqrt{\\frac{\\hat{\\sigma}^2}{\\sum_{i=1}^{n}(X_i &#8211; \\bar{X})^2}}$$<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306b\u95a2\u3059\u308b\u691c\u5b9a\uff08t\u691c\u5b9a\uff09<\/h2>\n\n\n\n<p>\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u3001\u3064\u307e\u308a\u56de\u5e30\u4fc2\u6570$\\beta_1$\u304c\u7d71\u8a08\u7684\u306b0\u3068\u7570\u306a\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3059\u308b\u305f\u3081\u306b\u306f\u3001<strong>t\u691c\u5b9a<\/strong>\u3092\u7528\u3044\u308b\u3002\u5e30\u7121\u4eee\u8aac\u306f\u300c$\\beta_1 = 0$\u300d\uff08$X$\u3068$Y$\u306e\u9593\u306b\u7dda\u5f62\u306a\u95a2\u4fc2\u304c\u306a\u3044\uff09\u3001\u5bfe\u7acb\u4eee\u8aac\u306f\u300c$\\beta_1 \\ne 0$\u300d\uff08$X$\u3068$Y$\u306e\u9593\u306b\u7dda\u5f62\u306a\u95a2\u4fc2\u304c\u3042\u308b\uff09\u3068\u306a\u308b\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>t\u5024<\/strong><\/li>\n<\/ul>\n\n\n\n<p>$$t = \\frac{\\hat{\\beta}_1 &#8211; 0}{SE(\\hat{\\beta}_1)}$$<\/p>\n\n\n\n<p>\u3053\u306et\u5024\u306f\u81ea\u7531\u5ea6$n-2$\u306et\u5206\u5e03\u306b\u5f93\u3046\u3002\u3053\u306et\u5024\u304b\u3089<strong>p\u5024<\/strong>\u3092\u8a08\u7b97\u3057\u3001\u6709\u610f\u6c34\u6e96\uff08\u901a\u5e38\u306f0.05\uff09\u3068\u6bd4\u8f03\u3059\u308b\u3053\u3068\u3067\u3001\u5e30\u7121\u4eee\u8aac\u3092\u68c4\u5374\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3059\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e95%\u4fe1\u983c\u533a\u9593<\/h2>\n\n\n\n<p>\u63a8\u5b9a\u3055\u308c\u305f\u56de\u5e30\u4fc2\u6570$\\hat{\\beta}_1$\u304c\u3001\u771f\u306e\u56de\u5e30\u4fc2\u6570$\\beta_1$\u3092\u3069\u306e\u7a0b\u5ea6\u306e\u7bc4\u56f2\u3067\u542b\u3080\u304b\u3092<strong>95%\u4fe1\u983c\u533a\u9593<\/strong>\u3068\u3057\u3066\u793a\u3059\u3002\u3053\u308c\u306f\u3001\u3082\u3057\u540c\u3058\u3088\u3046\u306a\u5206\u6790\u3092100\u500b\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u3001100\u56de\u7e70\u308a\u8fd4\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u3046\u306195\u56de\u306f\u771f\u306e\u56de\u5e30\u4fc2\u6570\u304c\u3053\u306e\u533a\u9593\u5185\u306b\u53ce\u307e\u308b\u3068\u3044\u3046\u53ef\u80fd\u6027\u304c\u3042\u308b\u533a\u9593\u3092\u610f\u5473\u3059\u308b\uff08\u624b\u6301\u3061\u306e\u30c7\u30fc\u30bf\u306f\u3001100 \u500b\u306e\u30b5\u30f3\u30d7\u30eb\u306e\u3046\u3061\u306e\u4e00\u3064\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\u3002\u771f\u306e\u56de\u5e30\u4fc2\u6570\u306f\u3001\u4e0d\u660e\u3060\u304c\u4e00\u3064\u306a\u306e\u3067\u3001\u3044\u304f\u3064\u3082\u5b58\u5728\u3057\u3046\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u3053\u3068\u306b\u6ce8\u610f\uff09<\/p>\n\n\n\n<p>$$\\hat{\\beta}_1 \\pm t_{\\alpha\/2, n-2} \\times SE(\\hat{\\beta}_1)$$<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u3001$t_{\\alpha\/2, n-2}$\u306f\u81ea\u7531\u5ea6$n-2$\u306et\u5206\u5e03\u306b\u304a\u3051\u308b\u4e0a\u5074$\\alpha\/2$\u70b9\uff0895%\u4fe1\u983c\u533a\u9593\u3067\u306f$\\alpha=0.05$\u306a\u306e\u3067\u4e0a\u50740.025\u70b9\uff09\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">R\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306e\u5b9f\u88c5\u3068 lm \u3068\u306e\u6bd4\u8f03<\/h2>\n\n\n\n<p>\u305d\u308c\u3067\u306f\u3001\u4e0a\u8a18\u3067\u89e3\u8aac\u3057\u305f\u8a08\u7b97\u3092R\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u5b9f\u88c5\u3057\u3001R\u306e\u6a19\u6e96\u95a2\u6570\u3067\u3042\u308b<code>lm<\/code>\u306e\u51fa\u529b\u3068\u6bd4\u8f03\u3057\u3066\u307f\u3088\u3046\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u30c7\u30fc\u30bf\u306e\u6e96\u5099\nset.seed(123)\nX &lt;- 1:100 + rnorm(100, 0, 10)\nY &lt;- 2 * X + 5 + rnorm(100, 0, 20)\ndata_df &lt;- data.frame(X = X, Y = Y)\n\n# 1. \u6700\u5c0f\u4e8c\u4e57\u6cd5\u306b\u3088\u308b\u56de\u5e30\u4fc2\u6570\u306e\u63a8\u5b9a\nn &lt;- length(X)\nmean_X &lt;- mean(X)\nmean_Y &lt;- mean(Y)\nprint(c(n, mean_X, mean_Y))\n\n# \u03b21 (\u50be\u304d) \u306e\u63a8\u5b9a\nbeta1_hat &lt;- sum((X - mean_X) * (Y - mean_Y)) \/ sum((X - mean_X)^2)\nprint(beta1_hat)\n\n# \u03b20 (\u5207\u7247) \u306e\u63a8\u5b9a\nbeta0_hat &lt;- mean_Y - beta1_hat * mean_X\nprint(beta0_hat)\n\ncat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u63a8\u5b9a\u5024 ---\\n\")\ncat(sprintf(\"\u5207\u7247 (beta0_hat): %.4f\\n\", beta0_hat))\ncat(sprintf(\"\u50be\u304d (beta1_hat): %.4f\\n\\n\", beta1_hat))\n\n# 2. \u6b8b\u5dee\u5206\u6563\u306e\u63a8\u5b9a\u3068\u6a19\u6e96\u8aa4\u5dee\u306e\u8a08\u7b97\n# \u4e88\u6e2c\u5024 (\u56de\u5e30\u76f4\u7dda\u4e0a\u306eY\u306e\u5024)\nY_pred &lt;- beta0_hat + beta1_hat * X\n\n# \u6b8b\u5dee\u5e73\u65b9\u548c (RSS)\nRSS &lt;- sum((Y - Y_pred)^2)\n\n# \u6b8b\u5dee\u5206\u6563\u306e\u63a8\u5b9a (MSE)\nsigma_squared_hat &lt;- RSS \/ (n - 2)\n\n# \u56de\u5e30\u4fc2\u6570 (beta1) \u306e\u6a19\u6e96\u8aa4\u5dee\nse_beta1 &lt;- sqrt(sigma_squared_hat \/ sum((X - mean_X)^2))\n\ncat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e\u6a19\u6e96\u8aa4\u5dee ---\\n\")\ncat(sprintf(\"\u50be\u304d (beta1) \u306e\u6a19\u6e96\u8aa4\u5dee: %.4f\\n\\n\", se_beta1))\n\n# 3. \u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306b\u95a2\u3059\u308b\u691c\u5b9a (t\u691c\u5b9a)\n# t\u5024\nt_value_beta1 &lt;- beta1_hat \/ se_beta1\n\n# \u81ea\u7531\u5ea6\ndf &lt;- n - 2\n\n# p\u5024 (\u4e21\u5074\u691c\u5b9a)\np_value_beta1 &lt;- 2 * pt(abs(t_value_beta1), df, lower.tail = FALSE)\n\ncat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e\u691c\u5b9a\u7d50\u679c ---\\n\")\ncat(sprintf(\"\u50be\u304d (beta1) \u306et\u5024: %.4f\\n\", t_value_beta1))\ncat(sprintf(\"\u81ea\u7531\u5ea6: %d\\n\", df))\nifelse(p_value_beta1 &lt; 0.001, \"p\u5024: &lt;0.001\", cat(sprintf(\"p\u5024: %.3f\\n\\n\", p_value_beta1)))\n\n# 4. 95%\u4fe1\u983c\u533a\u9593\u306e\u8a08\u7b97\n# \u6709\u610f\u6c34\u6e96 \u03b1 = 0.05\nalpha &lt;- 0.05\n\n# t\u5206\u5e03\u306e\u4e0a\u5074 \u03b1\/2 \u70b9\nt_critical &lt;- qt(1 - alpha\/2, df)\n\n# \u4fe1\u983c\u533a\u9593\u306e\u4e0b\u9650\nconf_int_lower &lt;- beta1_hat - t_critical * se_beta1\n\n# \u4fe1\u983c\u533a\u9593\u306e\u4e0a\u9650\nconf_int_upper &lt;- beta1_hat + t_critical * se_beta1\n\ncat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b95%\u4fe1\u983c\u533a\u9593 ---\\n\")\ncat(sprintf(\"95%%\u4fe1\u983c\u533a\u9593: &#91;%.4f, %.4f]\\n\\n\", conf_int_lower, conf_int_upper))\n\n\n# lm\u95a2\u6570\u306b\u3088\u308b\u7d50\u679c\u3068\u306e\u6bd4\u8f03\ncat(\"--- lm\u95a2\u6570\u306b\u3088\u308b\u56de\u5e30\u5206\u6790\u7d50\u679c ---\\n\")\nlm_model &lt;- lm(Y ~ X, data = data_df)\nprint(summary(lm_model))\nconfint(lm_model)\n<\/code><\/pre>\n\n\n\n<p><strong>\u5b9f\u884c\u7d50\u679c\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> cat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u63a8\u5b9a\u5024 ---\\n\")\n--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u63a8\u5b9a\u5024 ---\n> cat(sprintf(\"\u5207\u7247 (beta0_hat): %.4f\\n\", beta0_hat))\n\u5207\u7247 (beta0_hat): 0.4487\n> cat(sprintf(\"\u50be\u304d (beta1_hat): %.4f\\n\\n\", beta1_hat))\n\u50be\u304d (beta1_hat): 2.0467\n\n> cat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e\u6a19\u6e96\u8aa4\u5dee ---\\n\")\n--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e\u6a19\u6e96\u8aa4\u5dee ---\n> cat(sprintf(\"\u50be\u304d (beta1) \u306e\u6a19\u6e96\u8aa4\u5dee: %.4f\\n\\n\", se_beta1))\n\u50be\u304d (beta1) \u306e\u6a19\u6e96\u8aa4\u5dee: 0.0626\n\n> cat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e\u691c\u5b9a\u7d50\u679c ---\\n\")\n--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b\u56de\u5e30\u76f4\u7dda\u306e\u50be\u304d\u306e\u691c\u5b9a\u7d50\u679c ---\n> cat(sprintf(\"\u50be\u304d (beta1) \u306et\u5024: %.4f\\n\", t_value_beta1))\n\u50be\u304d (beta1) \u306et\u5024: 32.6750\n> cat(sprintf(\"\u81ea\u7531\u5ea6: %d\\n\", df))\n\u81ea\u7531\u5ea6: 98\n> if (p_value_beta1 &lt; 0.001) {\n+   cat(\"p\u5024: &lt;0.001\\n\\n\")\n+ } else {\n+   cat(sprintf(\"p\u5024: %.3f\\n\\n\", p_value_beta1))\n+ }\np\u5024: &lt;0.001\n\n> cat(\"--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b95%\u4fe1\u983c\u533a\u9593 ---\\n\")\n--- \u624b\u52d5\u8a08\u7b97\u306b\u3088\u308b95%\u4fe1\u983c\u533a\u9593 ---\n> cat(sprintf(\"95%%\u4fe1\u983c\u533a\u9593: &#91;%.4f, %.4f]\\n\\n\", conf_int_lower, conf_int_upper))\n95%\u4fe1\u983c\u533a\u9593: &#91;1.9224, 2.1710]\n\n> cat(\"--- lm\u95a2\u6570\u306b\u3088\u308b\u56de\u5e30\u5206\u6790\u7d50\u679c ---\\n\")\n--- lm\u95a2\u6570\u306b\u3088\u308b\u56de\u5e30\u5206\u6790\u7d50\u679c ---\n> lm_model &lt;- lm(Y ~ X, data = data_df)\n> summary(lm_model)\n\nCall:\nlm(formula = Y ~ X, data = data_df)\n\nResiduals:\n    Min      1Q  Median      3Q     Max \n-38.532 -13.507  -1.954  11.070  66.859 \n\nCoefficients:\n            Estimate Std. Error t value Pr(>|t|)    \n(Intercept)  0.44871    3.75826   0.119    0.905    \nX            2.04670    0.06264  32.675   &lt;2e-16 ***\n---\nSignif. codes:  0 \u2018***\u2019 0.001 \u2018**\u2019 0.01 \u2018*\u2019 0.05 \u2018.\u2019 0.1 \u2018 \u2019 1\n\nResidual standard error: 19.38 on 98 degrees of freedom\nMultiple R-squared:  0.9159,    Adjusted R-squared:  0.9151 \nF-statistic:  1068 on 1 and 98 DF,  p-value: &lt; 2.2e-16\n\n> confint(lm_model)\n                2.5 %   97.5 %\n(Intercept) -7.009437 7.906858\nX            1.922393 2.170999\n\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8a18\u306e\u5b9f\u884c\u7d50\u679c\u3092\u898b\u308b\u3068\u3001\u624b\u52d5\u3067\u8a08\u7b97\u3057\u305f\u63a8\u5b9a\u5024\u3001\u6a19\u6e96\u8aa4\u5dee\u3001t\u5024\u3001p\u5024\u300195%\u4fe1\u983c\u533a\u9593\u304c\u3001<code>lm<\/code>\u95a2\u6570\u306e<code>summary()<\/code>\u304a\u3088\u3073<code>confint()<\/code>\u95a2\u6570\u304c\u51fa\u529b\u3059\u308b\u7d50\u679c\u3068\u307b\u307c\u5b8c\u5168\u306b\u4e00\u81f4\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002\u308f\u305a\u304b\u306a\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u9055\u3044\u306f\u3001\u6d6e\u52d5\u5c0f\u6570\u70b9\u8a08\u7b97\u306e\u4e38\u3081\u8aa4\u5dee\u306b\u3088\u308b\u3082\u306e\u3060\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001R\u306e<code>lm<\/code>\u95a2\u6570\u3092\u4f7f\u308f\u305a\u306b\u3001\u5358\u56de\u5e30\u5206\u6790\u306b\u304a\u3051\u308b<strong>\u56de\u5e30\u76f4\u7dda\u306e\u691c\u5b9a<\/strong>\uff08\u5177\u4f53\u7684\u306b\u306f\u50be\u304d\u3067\u3042\u308b\u56de\u5e30\u4fc2\u6570\u306e\u691c\u5b9a\uff09\u3068<strong>\u4fe1\u983c\u533a\u9593<\/strong>\u306e\u8a08\u7b97\u3092\u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7\u3067\u5b9f\u88c5\u3057\u305f\u3002\u3053\u308c\u306b\u3088\u308a\u3001<code>lm<\/code>\u95a2\u6570\u304c\u5185\u90e8\u3067\u884c\u3063\u3066\u3044\u308b\u7d71\u8a08\u7684\u8a08\u7b97\u306e\u30ed\u30b8\u30c3\u30af\u3092\u6df1\u304f\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u306e\u3067\u306f\u306a\u3044\u3060\u308d\u3046\u304b\u3002<\/p>\n\n\n\n<p>\u7d71\u8a08\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306f\u975e\u5e38\u306b\u4fbf\u5229\u306a\u30c4\u30fc\u30eb\u3060\u304c\u3001\u305d\u306e\u88cf\u5074\u306e\u539f\u7406\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u9069\u5207\u306b\u5206\u6790\u7d50\u679c\u3092\u89e3\u91c8\u3057\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306b\u81ea\u4fe1\u3092\u6301\u3063\u3066\u53d6\u308a\u7d44\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3060\u308d\u3046\u3002\u4eca\u56de\u306e\u89e3\u8aac\u304c\u3001\u56de\u5e30\u76f4\u7dda\u306e\u7406\u89e3\u3092\u6df1\u3081\u308b\u4e00\u52a9\u3068\u306a\u308c\u3070\u5e78\u3044\u3060\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>\u5358\u56de\u5e30\u5206\u6790\u3067\u306f\u3001\u76ee\u7684\u5909\u6570\u3068\u8aac\u660e\u5909\u6570\u306e\u9593\u306b\u76f4\u7dda\u7684\u306a\u95a2\u4fc2\u304c\u3042\u308b\u304b\u3092\u8abf\u3079\u308b\u3002R\u306elm\u95a2\u6570\u3092\u4f7f\u3048\u3070\u7c21\u5358\u306b\u5206\u6790\u3067\u304d\u308b\u304c\u3001\u305d\u306e\u88cf\u5074\u306b\u3042\u308b\u8a08\u7b97\u30ed\u30b8\u30c3\u30af\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3082\u91cd\u8981\u3060\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001lm\u95a2\u6570\u306b\u983c\u3089\u305a\u306b\u56de\u5e30\u76f4\u7dda\u306e\u4e3b\u8981\u306a\u8981\u7d20\u3001\u3064\u307e\u308a [&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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[23],"tags":[],"class_list":["post-4283","post","type-post","status-publish","format-standard","hentry","category-23"],"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\/4283","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=4283"}],"version-history":[{"count":7,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/4283\/revisions"}],"predecessor-version":[{"id":4290,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/4283\/revisions\/4290"}],"wp:attachment":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/media?parent=4283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/categories?post=4283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/tags?post=4283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}