{"id":507,"date":"2023-07-29T16:34:41","date_gmt":"2023-07-29T16:34:41","guid":{"rendered":"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/"},"modified":"2023-07-29T16:34:41","modified_gmt":"2023-07-29T16:34:41","slug":"%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92","status":"publish","type":"post","link":"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/","title":{"rendered":"\u5982\u4f55\u5728 r \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u672c\u6307\u5357\u5c55\u793a\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c<a href=\"https:\/\/statorials.org\/cn\/\u591a\u5143\u7ebf\u6027\u56de\u5f52-1\/\" target=\"_blank\" rel=\"noopener\">\u591a\u5143\u7ebf\u6027\u56de\u5f52<\/a>\u7684\u793a\u4f8b\uff0c\u5305\u62ec\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u5728\u62df\u5408\u6a21\u578b\u4e4b\u524d\u68c0\u67e5\u6570\u636e<\/span><\/li>\n<li><span style=\"color: #000000;\">\u578b\u53f7\u8c03\u6574<\/span><\/li>\n<li><span style=\"color: #000000;\">\u68c0\u67e5\u6a21\u578b\u5047\u8bbe<\/span><\/li>\n<li><span style=\"color: #000000;\">\u89e3\u91ca\u6a21\u578b\u8f93\u51fa<\/span><\/li>\n<li><span style=\"color: #000000;\">\u8bc4\u4f30\u6a21\u578b\u7684\u62df\u5408\u4f18\u5ea6<\/span><\/li>\n<li><span style=\"color: #000000;\">\u4f7f\u7528\u6a21\u578b\u8fdb\u884c\u9884\u6d4b<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u8d70\u5427\uff01<\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u8bbe\u65bd<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u5185\u7f6e\u7684 R \u6570\u636e\u96c6<a href=\"https:\/\/statorials.org\/cn\/mtcars-r-\u6570\u636e\u96c6\/\" target=\"_blank\" rel=\"noopener\"><em>mtcars<\/em><\/a> \uff0c\u5176\u4e2d\u5305\u542b 32 \u8f86\u4e0d\u540c\u6c7d\u8f66\u7684\u5404\u79cd\u5c5e\u6027\u7684\u4fe1\u606f\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view first six lines of <em>mtcars<\/em><\/span>\nhead(mtcars)\n\n# mpg cyl disp hp drat wt qsec vs am gear carb\n#Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4\n#Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4\n#Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1\n#Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1\n#Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2\n#Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1\n<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u6784\u5efa\u4e00\u4e2a\u591a\u5143\u7ebf\u6027\u56de\u5f52\u6a21\u578b\uff0c\u4f7f\u7528<em>mpg<\/em>\u4f5c\u4e3a\u54cd\u5e94\u53d8\u91cf\uff0c\u4f7f\u7528<em>disp<\/em> \u3001 <em>hp<\/em>\u548c<em>drat<\/em>\u4f5c\u4e3a\u9884\u6d4b\u53d8\u91cf\u3002<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create new data frame that contains only the variables we would like to use to\n<\/span>data &lt;- mtcars[, c(\"mpg\", \"disp\", \"hp\", \"drat\")]\n\n<span style=\"color: #008080;\">#view first six rows of new data frame\n<span style=\"color: #000000;\">head(data)\n\n# mpg disp hp drat\n#Mazda RX4 21.0 160 110 3.90\n#Mazda RX4 Wag 21.0 160 110 3.90\n#Datsun 710 22.8 108 93 3.85\n#Hornet 4 Drive 21.4 258 110 3.08\n#Hornet Sportabout 18.7 360 175 3.15\n#Valiant 18.1 225 105 2.76<\/span><\/span><\/strong><\/pre>\n<h3><span style=\"color: #000000;\"><strong>\u6570\u636e\u5ba1\u6838<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u5728\u62df\u5408\u6a21\u578b\u4e4b\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u6570\u636e\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u5b83\uff0c\u5e76\u76f4\u89c2\u5730\u8bc4\u4f30\u591a\u5143\u7ebf\u6027\u56de\u5f52\u662f\u5426\u662f\u62df\u5408\u8be5\u6570\u636e\u7684\u826f\u597d\u6a21\u578b\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u7279\u522b\u662f\uff0c\u6211\u4eec\u9700\u8981\u68c0\u67e5\u9884\u6d4b\u53d8\u91cf\u4e0e\u54cd\u5e94\u53d8\u91cf\u662f\u5426\u5177\u6709<em>\u7ebf\u6027<\/em>\u5173\u8054\uff0c\u8fd9\u8868\u660e\u591a\u5143\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u53ef\u80fd\u662f\u5408\u9002\u7684\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u4e3a\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<strong>pairs()<\/strong>\u51fd\u6570\u521b\u5efa\u6bcf\u4e2a\u53ef\u80fd\u7684\u53d8\u91cf\u5bf9\u7684\u6563\u70b9\u56fe\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>pairs(data, pch = 18, col = \"steelblue\")<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u4ece\u8fd9\u5bf9\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><em>mpg<\/em>\u548c<em>\u53ef\u7528\u6027<\/em>\u4f3c\u4e4e\u5177\u6709\u5f88\u5f3a\u7684\u8d1f\u7ebf\u6027\u76f8\u5173\u6027<\/span><\/li>\n<li><span style=\"color: #000000;\"><em>mpg<\/em>\u548c<em>hp<\/em>\u4f3c\u4e4e\u5177\u6709\u5f88\u5f3a\u7684\u6b63\u7ebf\u6027\u76f8\u5173\u6027<\/span><\/li>\n<li><span style=\"color: #000000;\"><em>mpg<\/em>\u548c<em>drat<\/em>\u4f3c\u4e4e\u5177\u6709\u9002\u5ea6\u7684\u8d1f\u7ebf\u6027\u76f8\u5173\u6027<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u8bf7\u6ce8\u610f\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528<strong>GGally<\/strong>\u5e93\u4e2d\u7684<strong>ggpairs()<\/strong>\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u7c7b\u4f3c\u7684\u56fe\uff0c\u5176\u4e2d\u5305\u542b\u6bcf\u5bf9\u53d8\u91cf\u7684\u5b9e\u9645<a href=\"https:\/\/statorials.org\/cn\/\u76ae\u5c14\u900a\u76f8\u5173\u7cfb\u6570-1\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u7ebf\u6027\u76f8\u5173\u7cfb\u6570<\/a>\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#install and load the <em>GGally<\/em> library<\/span>\ninstall.packages(\"GGally\")\nlibrary(GGally)\n\n<span style=\"color: #008080;\">#generate the pairs plot\n<\/span>ggpairs(data)<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u6bcf\u4e2a\u9884\u6d4b\u53d8\u91cf\u4f3c\u4e4e\u4e0e\u54cd\u5e94\u53d8\u91cf<em>mpg<\/em>\u5177\u6709\u663e\u7740\u7684\u7ebf\u6027\u76f8\u5173\u6027\uff0c\u56e0\u6b64\u6211\u4eec\u5c06\u7ee7\u7eed\u5c06\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u62df\u5408\u5230\u6570\u636e\u3002<\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u578b\u53f7\u8c03\u6574<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u5728 R \u4e2d\u62df\u5408\u591a\u5143\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u7684\u57fa\u672c\u8bed\u6cd5\u662f\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>lm(response_variable ~ predictor_variable1 + predictor_variable2 + ..., data = data)<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u4f7f\u7528\u6211\u4eec\u7684\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u62df\u5408\u6a21\u578b\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>model &lt;- lm(mpg ~ disp + hp + drat, data = data)<\/strong><\/pre>\n<h3><span style=\"color: #000000;\"><strong>\u68c0\u67e5\u6a21\u578b\u5047\u8bbe<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u5728\u7ee7\u7eed\u9a8c\u8bc1\u6a21\u578b\u7ed3\u679c\u4e4b\u524d\uff0c\u6211\u4eec\u5fc5\u987b\u9996\u5148\u9a8c\u8bc1\u6a21\u578b\u5047\u8bbe\u662f\u5426\u5f97\u5230\u6ee1\u8db3\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u9700\u8981\u68c0\u67e5\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/span><\/p>\n<p> <strong><span style=\"color: #000000;\">1. \u6a21\u578b\u6b8b\u5dee\u7684\u5206\u5e03\u5e94\u8fd1\u4f3c\u6b63\u6001\u3002<\/span><\/strong><\/p>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u6b8b\u5dee\u76f4\u65b9\u56fe\u6765\u68c0\u67e5\u662f\u5426\u6ee1\u8db3\u8fd9\u4e2a\u5047\u8bbe\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>hist(residuals(model), col = \"steelblue\")\n<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u5c3d\u7ba1\u5206\u5e03\u7a0d\u5fae<a href=\"https:\/\/statorials.org\/cn\/\u5de6\u504f\u4e0e\u53f3\u504f\/\" target=\"_blank\" rel=\"noopener\">\u53f3\u504f<\/a>\uff0c\u4f46\u8fd8\u6ca1\u6709\u5f02\u5e38\u5230\u5f15\u8d77\u91cd\u5927\u5173\u6ce8\u7684\u7a0b\u5ea6\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>2. \u6240\u6709\u89c2\u6d4b\u503c\u7684\u6b8b\u5dee\u65b9\u5dee\u5fc5\u987b\u4e00\u81f4\u3002<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">\u8fd9\u79cd\u4f18\u9009\u6761\u4ef6\u79f0\u4e3a\u540c\u65b9\u5dee\u3002\u8fdd\u53cd\u8fd9\u4e00\u5047\u8bbe\u79f0\u4e3a<a href=\"https:\/\/statorials.org\/cn\/\u7edf\u8ba1\u5b66\u4ee5\u7b80\u5355\u76f4\u63a5\u7684\u65b9\u5f0f\u89e3\u91ca\u6982\u5ff5\uff0c\u6211\u4eec\u4f7f\u5b66\u4e60\u7edf\u8ba1\u53d8\u5f97\u66f4\u5bb9\u6613\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u5f02\u65b9\u5dee<\/a>\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u4e3a\u4e86\u68c0\u67e5\u662f\u5426\u6ee1\u8db3\u8fd9\u4e2a\u5047\u8bbe\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a<em>\u8c03\u6574\/\u6b8b\u503c\u56fe\uff1a<\/em><\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create fitted value vs residual plot<\/span>\nplot(fitted(model), residuals(model))\n\n<span style=\"color: #008080;\">#add horizontal line at 0\n<\/span>abline(h = 0, lty = 2)<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u7406\u60f3\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u6b8b\u5dee\u5728\u6bcf\u4e2a\u62df\u5408\u503c\u4e0a\u5747\u5300\u5206\u5e03\u3002\u4ece\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u62df\u5408\u503c\u8d8a\u5927\uff0c\u79bb\u5dee\u5f80\u5f80\u4f1a\u53d8\u5927\u4e00\u4e9b\uff0c\u4f46\u8fd9\u79cd\u8d8b\u52bf\u8fd8\u6ca1\u6709\u6781\u7aef\u5230\u5f15\u8d77\u592a\u591a\u5173\u6ce8\u3002<\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u89e3\u91ca\u6a21\u578b\u8f93\u51fa<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u4e00\u65e6\u6211\u4eec\u9a8c\u8bc1\u4e86\u6a21\u578b\u5047\u8bbe\u5f97\u5230\u5145\u5206\u6ee1\u8db3\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528<strong>summary()<\/strong>\u51fd\u6570\u68c0\u67e5\u6a21\u578b\u8f93\u51fa\uff1a<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>summary(model)\n\n#Call:\n#lm(formula = mpg ~ disp + hp + drat, data = data)\n#\n#Residuals:\n# Min 1Q Median 3Q Max \n#-5.1225 -1.8454 -0.4456 1.1342 6.4958 \n#\n#Coefficients:\n#Estimate Std. Error t value Pr(&gt;|t|)   \n#(Intercept) 19.344293 6.370882 3.036 0.00513 **\n#disp -0.019232 0.009371 -2.052 0.04960 * \n#hp -0.031229 0.013345 -2.340 0.02663 * \n#drat 2.714975 1.487366 1.825 0.07863 . \n#---\n#Significant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n#\n#Residual standard error: 3.008 on 28 degrees of freedom\n#Multiple R-squared: 0.775, Adjusted R-squared: 0.7509 \n#F-statistic: 32.15 on 3 and 28 DF, p-value: 3.28e-09\n<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u4ece\u7ed3\u679c\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u6a21\u578b\u7684\u603b\u4f53 F \u7edf\u8ba1\u91cf\u4e3a<strong>32.15<\/strong> \uff0c\u76f8\u5e94\u7684 p \u503c\u4e3a<strong>3.28e-09<\/strong> \u3002\u8fd9\u8868\u660e\u6574\u4f53\u6a21\u578b\u5177\u6709\u7edf\u8ba1\u663e\u7740\u6027\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u56de\u5f52\u6a21\u578b\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\u662f\u6709\u7528\u7684\u3002<\/span><\/li>\n<li> <span style=\"color: #000000;\"><em>disp<\/em>\u5728 0.10 \u663e\u7740\u6027\u6c34\u5e73\u4e0a\u5177\u6709\u7edf\u8ba1\u663e\u7740\u6027\u3002\u7279\u522b\u662f\uff0c\u6a21\u578b\u7ed3\u679c\u7684\u7cfb\u6570\u8868\u660e\uff0c\u5047\u8bbe<em>\u9a6c\u529b<\/em>\u548c<em>\u6cb9\u8017<\/em>\u4fdd\u6301\u4e0d\u53d8\uff0c<em>\u53ef\u7528\u6027<\/em>\u589e\u52a0 1 \u4e2a\u5355\u4f4d\u4e0e\u5e73\u5747<em>mpg<\/em>\u51cf\u5c11 -0.019 \u4e2a\u5355\u4f4d\u76f8\u5173\u3002 \u3002<\/span><\/li>\n<li> <span style=\"color: #000000;\"><em>hp<\/em>\u5728 0.10 \u663e\u7740\u6027\u6c34\u5e73\u4e0a\u5177\u6709\u7edf\u8ba1\u663e\u7740\u6027\u3002\u7279\u522b\u662f\uff0c\u6a21\u578b\u7ed3\u679c\u7684\u7cfb\u6570\u8868\u660e\uff0c\u5047\u8bbe<i>disp<\/i>\u548c<em>drat<\/em>\u4fdd\u6301\u4e0d\u53d8\uff0c\u5219<i>\u9a6c\u529b<\/i>\u6bcf\u589e\u52a0 1 \u4e2a\u5355\u4f4d\uff0c\u5e73\u5747<em>mpg<\/em>\u5c31\u4f1a\u51cf\u5c11 -0.031 \u4e2a\u5355\u4f4d\u3002<\/span><\/li>\n<li> <span style=\"color: #000000;\"><em>drat<\/em>\u5728 0.10 \u663e\u7740\u6027\u6c34\u5e73\u4e0a\u5177\u6709\u7edf\u8ba1\u663e\u7740\u6027\u3002\u7279\u522b\u662f\uff0c\u6a21\u578b\u7ed3\u679c\u7684\u7cfb\u6570\u8868\u660e\uff0c\u5047\u8bbe<i>\u6d41\u91cf<\/i>\u548c<i>\u9a6c\u529b<\/i>\u4fdd\u6301\u4e0d\u53d8\uff0c<i>\u6c7d\u6cb9\u6d88\u8017<\/i>\u589e\u52a0 1 \u4e2a\u5355\u4f4d\u4e0e\u5e73\u5747 2,715 \u5355\u4f4d<em>mpg<\/em>\u7684\u589e\u52a0\u76f8\u5173\u3002<\/span><\/li>\n<\/ul>\n<h3><span style=\"color: #000000;\"><strong>\u8bc4\u4f30\u6a21\u578b\u7684\u62df\u5408\u4f18\u5ea6<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u4e3a\u4e86\u8bc4\u4f30\u56de\u5f52\u6a21\u578b\u5bf9\u6570\u636e\u7684\u62df\u5408\u7a0b\u5ea6\uff0c\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u4e00\u4e9b\u4e0d\u540c\u7684\u6307\u6807\uff1a<\/span><\/p>\n<p> <strong><span style=\"color: #000000;\">1. \u591a\u4e2aR\u65b9<\/span><\/strong><\/p>\n<p><span style=\"color: #000000;\">\u8fd9\u8861\u91cf\u4e86\u9884\u6d4b\u53d8\u91cf\u548c\u54cd\u5e94\u53d8\u91cf\u4e4b\u95f4\u7ebf\u6027\u5173\u7cfb\u7684\u5f3a\u5ea6\u3002 R \u5e73\u65b9\u500d\u6570\u4e3a 1 \u8868\u793a\u5b8c\u7f8e\u7ebf\u6027\u5173\u7cfb\uff0c\u800c R \u5e73\u65b9\u500d\u6570\u4e3a 0 \u8868\u793a\u6ca1\u6709\u7ebf\u6027\u5173\u7cfb\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u500d\u6570 R \u4e5f\u662f R \u5e73\u65b9\u7684\u5e73\u65b9\u6839\uff0c\u5b83\u662f\u54cd\u5e94\u53d8\u91cf\u4e2d\u53ef\u4ee5\u7531\u9884\u6d4b\u53d8\u91cf\u89e3\u91ca\u7684\u65b9\u5dee\u7684\u6bd4\u4f8b\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0cR \u5e73\u65b9\u500d\u6570\u4e3a<strong>0.775<\/strong> \u3002\u6240\u4ee5 R \u5e73\u65b9\u4e3a 0.775 <sup>2<\/sup> = <strong>0.601<\/strong> \u3002\u8fd9\u8868\u660e<i>mpg<\/i>\u4e2d<strong>60.1%<\/strong>\u7684\u65b9\u5dee\u53ef\u4ee5\u901a\u8fc7\u6a21\u578b\u9884\u6d4b\u53d8\u91cf\u6765\u89e3\u91ca\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>\u76f8\u5173\uff1a<\/strong> <a href=\"https:\/\/statorials.org\/cn\/\u7edf\u8ba1\u5b66\u4ee5\u7b80\u5355\u76f4\u63a5\u7684\u65b9\u5f0f\u89e3\u91ca\u6982\u5ff5\uff0c\u6211\u4eec\u4f7f\u5b66\u4e60\u7edf\u8ba1\u53d8\u5f97\u66f4\u5bb9\u6613\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u4ec0\u4e48\u662f\u597d\u7684 R \u5e73\u65b9\u503c\uff1f<\/a><\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>2. \u6b8b\u5dee\u6807\u51c6\u8bef\u5dee<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">\u8fd9\u6d4b\u91cf\u4e86\u89c2\u6d4b\u503c\u548c\u56de\u5f52\u7ebf\u4e4b\u95f4\u7684\u5e73\u5747\u8ddd\u79bb\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u89c2\u6d4b\u503c\u4e0e\u56de\u5f52\u7ebf\u5e73\u5747\u504f\u5dee<strong>3.008 \u4e2a\u5355\u4f4d<\/strong><strong>\u3002<\/strong><\/span><\/p>\n<p><strong><span style=\"color: #000000;\">\u6709\u5173\u7684\uff1a<\/span><\/strong> <span style=\"color: #000000;\">&nbsp;<\/span> <a href=\"https:\/\/statorials.org\/cn\/\u7edf\u8ba1\u5b66\u4ee5\u7b80\u5355\u76f4\u63a5\u7684\u65b9\u5f0f\u89e3\u91ca\u6982\u5ff5\uff0c\u6211\u4eec\u4f7f\u5b66\u4e60\u7edf\u8ba1\u53d8\u5f97\u66f4\u5bb9\u6613\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u4e86\u89e3\u56de\u5f52\u7684\u6807\u51c6\u8bef\u5dee<\/a><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u4f7f\u7528\u6a21\u578b\u8fdb\u884c\u9884\u6d4b<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u7531\u6a21\u578b\u7ed3\u679c\u53ef\u77e5\uff0c\u62df\u5408\u7684\u591a\u5143\u7ebf\u6027\u56de\u5f52\u65b9\u7a0b\u4e3a\uff1a<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"color: #000000;\"><sub>\u82f1\u91cc<\/sub>\/\u52a0\u4ed1 = -19.343 \u2013 0.019*disp \u2013 0.031*hp + 2.715*drat<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u65b9\u7a0b\u6765\u9884\u6d4b\u65b0<a href=\"https:\/\/statorials.org\/cn\/\u7edf\u8ba1\u89c2\u5bdf\/\" target=\"_blank\" rel=\"noopener\">\u89c2\u5bdf<\/a>\u7684<em>mpg<\/em>\u662f\u591a\u5c11\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u627e\u5230\u5177\u6709\u4ee5\u4e0b\u5c5e\u6027\u7684\u6c7d\u8f66\u7684\u9884\u6d4b<em>mpg<\/em>\u503c\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\"><em>\u663e\u793a<\/em>= 220<\/span><\/li>\n<li><span style=\"color: #000000;\"><em>\u901a\u9053<\/em>= 150<\/span><\/li>\n<li><span style=\"color: #000000;\"><em>\u5fb7\u62c9<\/em>= 3<\/span><\/li>\n<\/ul>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define the coefficients from the model output<\/span>\nintercept &lt;- coef(summary(model))[\"(Intercept)\", \"Estimate\"]\ndisp &lt;- coef(summary(model))[\"disp\", \"Estimate\"]\nhp &lt;- coef(summary(model))[\"hp\", \"Estimate\"]\ndrat &lt;- coef(summary(model))[\"drat\", \"Estimate\"]\n\n<span style=\"color: #008080;\">#use the model coefficients to predict the value for <em>mpg<\/em>\n<\/span>intercept + disp*220 + hp*150 + drat*3\n\n#[1] 18.57373<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u5bf9\u4e8e<em>disp<\/em> = 220\u3001 <em>hp<\/em> = 150 \u4e14<em>drat<\/em> = 3 \u7684\u6c7d\u8f66\uff0c\u6a21\u578b\u9884\u6d4b\u6c7d\u8f66\u7684\u6cb9\u8017\u4e3a<strong>18.57373<\/strong> <em>mpg<\/em> \u3002<\/span><\/p>\n<p><span style=\"color: #000000;\"><em>\u60a8\u53ef\u4ee5<a href=\"https:\/\/github.com\/Statorials\/R-Guides\/blob\/main\/multiple_linear_regression.R\" target=\"_blank\" rel=\"noopener noreferrer\">\u5728\u6b64\u5904<\/a>\u627e\u5230\u672c\u6559\u7a0b\u4e2d\u4f7f\u7528\u7684\u5b8c\u6574 R \u4ee3\u7801\u3002<\/em><\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u5176\u4ed6\u8d44\u6e90<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u4ee5\u4e0b\u6559\u7a0b\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u62df\u5408\u5176\u4ed6\u7c7b\u578b\u7684\u56de\u5f52\u6a21\u578b\uff1a<\/span><\/p>\n<p><a href=\"https:\/\/statorials.org\/cn\/\u4e8c\u6b21\u56de\u5f52-r\/\" target=\"_blank\" rel=\"noopener\">\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u4e8c\u6b21\u56de\u5f52<\/a><br \/><a href=\"https:\/\/statorials.org\/cn\/\u591a\u9879\u5f0f\u56de\u5f52-r\/\" target=\"_blank\" rel=\"noopener\">\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u9879\u5f0f\u56de\u5f52<\/a><br \/><a href=\"https:\/\/statorials.org\/cn\/r-\u4e2d\u7684\u6307\u6570\u56de\u5f52\/\">\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u6307\u6570\u56de\u5f52<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6307\u5357\u5c55\u793a\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u7684\u793a\u4f8b\uff0c\u5305\u62ec\uff1a \u5728\u62df\u5408\u6a21\u578b\u4e4b\u524d\u68c0\u67e5\u6570\u636e \u578b\u53f7\u8c03\u6574 \u68c0\u67e5\u6a21\u578b\u5047\u8bbe \u89e3\u91ca [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-11"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52 - Statorials<\/title>\n<meta name=\"description\" content=\"\u672c\u6307\u5357\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4ee5\u53ca\u5982\u4f55\u68c0\u67e5\u6a21\u578b\u5047\u8bbe\u548c\u8bc4\u4f30\u6a21\u578b\u62df\u5408\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/cn\/\u591a\u5143\u7ebf\u6027\u56de\u5f52\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52 - Statorials\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6307\u5357\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4ee5\u53ca\u5982\u4f55\u68c0\u67e5\u6a21\u578b\u5047\u8bbe\u548c\u8bc4\u4f30\u6a21\u578b\u62df\u5408\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/cn\/\u591a\u5143\u7ebf\u6027\u56de\u5f52\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-29T16:34:41+00:00\" \/>\n<meta name=\"author\" content=\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/\",\"url\":\"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/\",\"name\":\"\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52 - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/cn\/#website\"},\"datePublished\":\"2023-07-29T16:34:41+00:00\",\"dateModified\":\"2023-07-29T16:34:41+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261\"},\"description\":\"\u672c\u6307\u5357\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4ee5\u53ca\u5982\u4f55\u68c0\u67e5\u6a21\u578b\u5047\u8bbe\u548c\u8bc4\u4f30\u6a21\u578b\u62df\u5408\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u5bb6\",\"item\":\"https:\/\/statorials.org\/cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5982\u4f55\u5728 r \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/cn\/#website\",\"url\":\"https:\/\/statorials.org\/cn\/\",\"name\":\"Statorials\",\"description\":\"\u60a8\u7684\u7edf\u8ba1\u7d20\u517b\u6307\u5357\uff01\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/cn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261\",\"name\":\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/statorials.org\/cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\"},\"description\":\"\u5927\u5bb6\u597d\uff0c\u6211\u662f\u672c\u6770\u660e\uff0c\u4e00\u4f4d\u9000\u4f11\u7684\u7edf\u8ba1\u5b66\u6559\u6388\uff0c\u540e\u6765\u6210\u4e3a Statorials \u7684\u70ed\u5fc3\u6559\u5e08\u3002 \u51ed\u501f\u5728\u7edf\u8ba1\u9886\u57df\u7684\u4e30\u5bcc\u7ecf\u9a8c\u548c\u4e13\u4e1a\u77e5\u8bc6\uff0c\u6211\u6e34\u671b\u5206\u4eab\u6211\u7684\u77e5\u8bc6\uff0c\u901a\u8fc7 Statorials \u589e\u5f3a\u5b66\u751f\u7684\u80fd\u529b\u3002\u4e86\u89e3\u66f4\u591a\",\"sameAs\":[\"https:\/\/statorials.org\/cn\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52 - Statorials","description":"\u672c\u6307\u5357\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4ee5\u53ca\u5982\u4f55\u68c0\u67e5\u6a21\u578b\u5047\u8bbe\u548c\u8bc4\u4f30\u6a21\u578b\u62df\u5408\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/cn\/\u591a\u5143\u7ebf\u6027\u56de\u5f52\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52 - Statorials","og_description":"\u672c\u6307\u5357\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4ee5\u53ca\u5982\u4f55\u68c0\u67e5\u6a21\u578b\u5047\u8bbe\u548c\u8bc4\u4f30\u6a21\u578b\u62df\u5408\u3002","og_url":"https:\/\/statorials.org\/cn\/\u591a\u5143\u7ebf\u6027\u56de\u5f52\/","og_site_name":"Statorials","article_published_time":"2023-07-29T16:34:41+00:00","author":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/","url":"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/","name":"\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52 - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/cn\/#website"},"datePublished":"2023-07-29T16:34:41+00:00","dateModified":"2023-07-29T16:34:41+00:00","author":{"@id":"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261"},"description":"\u672c\u6307\u5357\u89e3\u91ca\u4e86\u5982\u4f55\u5728 R \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4ee5\u53ca\u5982\u4f55\u68c0\u67e5\u6a21\u578b\u5047\u8bbe\u548c\u8bc4\u4f30\u6a21\u578b\u62df\u5408\u3002","breadcrumb":{"@id":"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/cn\/%e5%a4%9a%e5%85%83%e7%ba%bf%e6%80%a7%e5%9b%9e%e5%bd%92\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u5bb6","item":"https:\/\/statorials.org\/cn\/"},{"@type":"ListItem","position":2,"name":"\u5982\u4f55\u5728 r \u4e2d\u6267\u884c\u591a\u5143\u7ebf\u6027\u56de\u5f52"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/cn\/#website","url":"https:\/\/statorials.org\/cn\/","name":"Statorials","description":"\u60a8\u7684\u7edf\u8ba1\u7d20\u517b\u6307\u5357\uff01","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/cn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261","name":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/statorials.org\/cn\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a"},"description":"\u5927\u5bb6\u597d\uff0c\u6211\u662f\u672c\u6770\u660e\uff0c\u4e00\u4f4d\u9000\u4f11\u7684\u7edf\u8ba1\u5b66\u6559\u6388\uff0c\u540e\u6765\u6210\u4e3a Statorials \u7684\u70ed\u5fc3\u6559\u5e08\u3002 \u51ed\u501f\u5728\u7edf\u8ba1\u9886\u57df\u7684\u4e30\u5bcc\u7ecf\u9a8c\u548c\u4e13\u4e1a\u77e5\u8bc6\uff0c\u6211\u6e34\u671b\u5206\u4eab\u6211\u7684\u77e5\u8bc6\uff0c\u901a\u8fc7 Statorials \u589e\u5f3a\u5b66\u751f\u7684\u80fd\u529b\u3002\u4e86\u89e3\u66f4\u591a","sameAs":["https:\/\/statorials.org\/cn"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/comments?post=507"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}