{"id":1198,"date":"2023-07-27T07:56:18","date_gmt":"2023-07-27T07:56:18","guid":{"rendered":"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/"},"modified":"2023-07-27T07:56:18","modified_gmt":"2023-07-27T07:56:18","slug":"%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/","title":{"rendered":"Lasso regression \u0e43\u0e19 r (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><a href=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso<\/a> \u0e40\u0e1b\u0e47\u0e19\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e0a\u0e49\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e1e\u0e2d\u0e14\u0e35\u0e01\u0e31\u0e1a\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e21\u0e35 <a href=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e2b\u0e25\u0e32\u0e22\u0e40\u0e2a\u0e49\u0e19\/\" target=\"_blank\" rel=\"noopener noreferrer\">multicollinearity<\/a> \u0e43\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e42\u0e14\u0e22\u0e2a\u0e23\u0e38\u0e1b \u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e01\u0e33\u0e25\u0e31\u0e07\u0e2a\u0e2d\u0e07\u0e19\u0e49\u0e2d\u0e22\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14\u0e1e\u0e22\u0e32\u0e22\u0e32\u0e21\u0e04\u0e49\u0e19\u0e2b\u0e32\u0e01\u0e32\u0e23\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e04\u0e48\u0e32\u0e2a\u0e31\u0e21\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e17\u0e35\u0e48\u0e25\u0e14\u0e1c\u0e25\u0e23\u0e27\u0e21\u0e17\u0e35\u0e48\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e02\u0e2d\u0e07\u0e01\u0e33\u0e25\u0e31\u0e07\u0e2a\u0e2d\u0e07 (RSS):<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>RSS = \u03a3(\u0e09\u0e31\u0e19 <sub>\u0e09\u0e31\u0e19<\/sub> \u2013 \u0177 <sub>\u0e09\u0e31\u0e19<\/sub> )2<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e17\u0e2d\u0e07:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>\u03a3<\/strong> : \u0e2a\u0e31\u0e0d\u0e25\u0e31\u0e01\u0e29\u0e13\u0e4c\u0e01\u0e23\u0e35\u0e01\u0e2b\u0e21\u0e32\u0e22\u0e16\u0e36\u0e07 <em>\u0e1c\u0e25\u0e23\u0e27\u0e21<\/em><\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>y <sub>i<\/sub><\/strong> : \u0e04\u0e48\u0e32\u0e15\u0e2d\u0e1a\u0e2a\u0e19\u0e2d\u0e07\u0e08\u0e23\u0e34\u0e07\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e2a\u0e31\u0e07\u0e40\u0e01\u0e15 <sup>\u0e04\u0e23\u0e31\u0e49\u0e07\u0e17\u0e35\u0e48 3<\/sup><\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>\u0177 <sub>i<\/sub><\/strong> : \u0e04\u0e48\u0e32\u0e15\u0e2d\u0e1a\u0e2a\u0e19\u0e2d\u0e07\u0e17\u0e35\u0e48\u0e04\u0e32\u0e14\u0e01\u0e32\u0e23\u0e13\u0e4c\u0e44\u0e27\u0e49\u0e15\u0e32\u0e21\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e40\u0e0a\u0e34\u0e07\u0e40\u0e2a\u0e49\u0e19\u0e1e\u0e2b\u0e38\u0e04\u0e39\u0e13<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">\u0e43\u0e19\u0e17\u0e32\u0e07\u0e01\u0e25\u0e31\u0e1a\u0e01\u0e31\u0e19 \u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso \u0e1e\u0e22\u0e32\u0e22\u0e32\u0e21\u0e25\u0e14\u0e2a\u0e34\u0e48\u0e07\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e19\u0e35\u0e49\u0e43\u0e2b\u0e49\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e19\u0e49\u0e2d\u0e22\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>RSS + \u03a3\u03a3|\u03b2 <sub>j<\/sub> |<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e42\u0e14\u0e22\u0e17\u0e35\u0e48 <em>j<\/em> \u0e44\u0e1b\u0e08\u0e32\u0e01 1 \u0e16\u0e36\u0e07 <em>p<\/em> \u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e17\u0e33\u0e19\u0e32\u0e22\u0e41\u0e25\u0e30 \u0e41\u0e25 \u2265 0<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e40\u0e17\u0e2d\u0e21\u0e17\u0e35\u0e48\u0e2a\u0e2d\u0e07\u0e43\u0e19\u0e2a\u0e21\u0e01\u0e32\u0e23\u0e19\u0e35\u0e49\u0e40\u0e23\u0e35\u0e22\u0e01\u0e27\u0e48\u0e32 <em>\u0e01\u0e32\u0e23\u0e25\u0e07\u0e42\u0e17\u0e29\u0e01\u0e32\u0e23\u0e16\u0e2d\u0e19<\/em> \u0e43\u0e19\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28 \u0e40\u0e23\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e04\u0e48\u0e32\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a \u03b3 \u0e17\u0e35\u0e48\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e01\u0e32\u0e23\u0e17\u0e14\u0e2a\u0e2d\u0e1a MSE (\u0e02\u0e49\u0e2d\u0e1c\u0e34\u0e14\u0e1e\u0e25\u0e32\u0e14\u0e01\u0e33\u0e25\u0e31\u0e07\u0e2a\u0e2d\u0e07\u0e40\u0e09\u0e25\u0e35\u0e48\u0e22) \u0e15\u0e48\u0e33\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14\u0e17\u0e35\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e44\u0e1b\u0e44\u0e14\u0e49<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e43\u0e2b\u0e49\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e02\u0e2d\u0e07\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e35\u0e48 1: \u0e42\u0e2b\u0e25\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e19\u0e35\u0e49 \u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19\u0e15\u0e31\u0e27\u0e02\u0e2d\u0e07 R \u0e17\u0e35\u0e48\u0e40\u0e23\u0e35\u0e22\u0e01\u0e27\u0e48\u0e32 <strong>mtcars<\/strong> \u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49 <strong>hp<\/strong> \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e15\u0e2d\u0e1a\u0e2a\u0e19\u0e2d\u0e07 \u0e41\u0e25\u0e30\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e19\u0e35\u0e49\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e17\u0e33\u0e19\u0e32\u0e22:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">mpg<\/span><\/li>\n<li> <span style=\"color: #000000;\">\u0e19\u0e49\u0e33\u0e2b\u0e19\u0e31\u0e01<\/span><\/li>\n<li> <span style=\"color: #000000;\">\u0e2d\u0e36<\/span><\/li>\n<li> <span style=\"color: #000000;\">\u0e04\u0e34\u0e27\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e17\u0e33\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28 \u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e08\u0e32\u0e01\u0e41\u0e1e\u0e47\u0e04\u0e40\u0e01\u0e08 <strong>glmnet<\/strong> \u0e41\u0e1e\u0e04\u0e40\u0e01\u0e08\u0e19\u0e35\u0e49\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49 <a href=\"https:\/\/statorials.org\/th\/\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e17\u0e35\u0e48\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e01\u0e32\u0e23\u0e15\u0e2d\u0e1a\u0e2a\u0e19\u0e2d\u0e07\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e15\u0e2d\u0e1a\u0e2a\u0e19\u0e2d\u0e07<\/a> \u0e40\u0e1b\u0e47\u0e19\u0e40\u0e27\u0e01\u0e40\u0e15\u0e2d\u0e23\u0e4c\u0e41\u0e25\u0e30\u0e0a\u0e38\u0e14\u0e02\u0e2d\u0e07\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e17\u0e33\u0e19\u0e32\u0e22\u0e15\u0e49\u0e2d\u0e07\u0e40\u0e1b\u0e47\u0e19\u0e02\u0e2d\u0e07\u0e04\u0e25\u0e32\u0e2a <strong>data.matrix<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e23\u0e2b\u0e31\u0e2a\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e19\u0e35\u0e49\u0e41\u0e2a\u0e14\u0e07\u0e27\u0e34\u0e18\u0e35\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e02\u0e2d\u0e07\u0e40\u0e23\u0e32:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define response variable<\/span>\ny &lt;- mtcars$hp\n\n<span style=\"color: #008080;\">#define matrix of predictor variables\n<\/span>x &lt;- data.matrix(mtcars[, c('mpg', 'wt', 'drat', 'qsec')])\n<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e35\u0e48 2: \u0e15\u0e34\u0e14\u0e15\u0e31\u0e49\u0e07\u0e42\u0e21\u0e40\u0e14\u0e25 Lasso Regression<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">\u0e15\u0e48\u0e2d\u0e44\u0e1b \u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 <strong>glmnet()<\/strong> \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e1e\u0e2d\u0e14\u0e35\u0e01\u0e31\u0e1a\u0e42\u0e21\u0e40\u0e14\u0e25\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso \u0e41\u0e25\u0e30\u0e23\u0e30\u0e1a\u0e38 <strong>alpha=1<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e42\u0e1b\u0e23\u0e14\u0e17\u0e23\u0e32\u0e1a\u0e27\u0e48\u0e32\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e2d\u0e31\u0e25\u0e1f\u0e48\u0e32\u0e40\u0e17\u0e48\u0e32\u0e01\u0e31\u0e1a 0 \u0e40\u0e17\u0e35\u0e22\u0e1a\u0e40\u0e17\u0e48\u0e32\u0e01\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49 <a href=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e22\u0e2d\u0e14\u0e43\u0e19-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e2a\u0e31\u0e19\u0e40\u0e02\u0e32<\/a> \u0e41\u0e25\u0e30\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e2d\u0e31\u0e25\u0e1f\u0e48\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e48\u0e32\u0e23\u0e30\u0e2b\u0e27\u0e48\u0e32\u0e07 0 \u0e16\u0e36\u0e07 1 \u0e40\u0e17\u0e35\u0e22\u0e1a\u0e40\u0e17\u0e48\u0e32\u0e01\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e15\u0e32\u0e02\u0e48\u0e32\u0e22\u0e41\u0e1a\u0e1a\u0e22\u0e37\u0e14\u0e2b\u0e22\u0e38\u0e48\u0e19<\/span> <span style=\"color: #000000;\"><strong>&nbsp;<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32\u0e27\u0e48\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e04\u0e48\u0e32\u0e43\u0e14\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e41\u0e25\u0e21\u0e1a\u0e4c\u0e14\u0e32 \u0e40\u0e23\u0e32\u0e08\u0e30\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19 <a href=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e02\u0e49\u0e32\u0e21\u0e1e\u0e31\u0e1a-k\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e02\u0e49\u0e32\u0e21 k-fold<\/a> \u0e41\u0e25\u0e30\u0e23\u0e30\u0e1a\u0e38\u0e04\u0e48\u0e32\u0e41\u0e25\u0e21\u0e1a\u0e4c\u0e14\u0e32\u0e17\u0e35\u0e48\u0e17\u0e33\u0e43\u0e2b\u0e49\u0e40\u0e01\u0e34\u0e14\u0e02\u0e49\u0e2d\u0e1c\u0e34\u0e14\u0e1e\u0e25\u0e32\u0e14\u0e01\u0e33\u0e25\u0e31\u0e07\u0e2a\u0e2d\u0e07\u0e40\u0e09\u0e25\u0e35\u0e48\u0e22\u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e15\u0e48\u0e33\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14 (MSE)<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e42\u0e1b\u0e23\u0e14\u0e17\u0e23\u0e32\u0e1a\u0e27\u0e48\u0e32\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 <strong>cv.glmnet()<\/strong> \u0e08\u0e30\u0e17\u0e33\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e02\u0e49\u0e32\u0e21 k-fold \u0e42\u0e14\u0e22\u0e2d\u0e31\u0e15\u0e42\u0e19\u0e21\u0e31\u0e15\u0e34\u0e42\u0e14\u0e22\u0e43\u0e0a\u0e49 k = 10 \u0e04\u0e23\u0e31\u0e49\u0e07<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #993300;\">library<\/span> (glmnet)<\/span>\n\n#perform k-fold cross-validation to find optimal lambda value\n<\/span>cv_model &lt;- cv. <span style=\"color: #3366ff;\">glmnet<\/span> (x, y, alpha = <span style=\"color: #008000;\">1<\/span> )\n\n<span style=\"color: #008080;\">#find optimal lambda value that minimizes test MSE\n<\/span>best_lambda &lt;- cv_model$ <span style=\"color: #3366ff;\">lambda<\/span> . <span style=\"color: #3366ff;\">min<\/span>\nbest_lambda\n\n[1] 5.616345\n\n<span style=\"color: #008080;\">#produce plot of test MSE by lambda value<\/span>\nplot(cv_model) \n<\/strong><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11896 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/lassor1.png\" alt=\"\u0e01\u0e32\u0e23\u0e17\u0e14\u0e2a\u0e2d\u0e1a MSE \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso \u0e43\u0e19 R\" width=\"419\" height=\"407\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">\u0e04\u0e48\u0e32\u0e41\u0e25\u0e21\u0e1a\u0e4c\u0e14\u0e32\u0e17\u0e35\u0e48\u0e22\u0e48\u0e2d\u0e01\u0e32\u0e23\u0e17\u0e14\u0e2a\u0e2d\u0e1a MSE \u0e43\u0e2b\u0e49\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e19\u0e49\u0e2d\u0e22\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14\u0e01\u0e25\u0e32\u0e22\u0e40\u0e1b\u0e47\u0e19 <strong>5.616345<\/strong><\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e35\u0e48 3: \u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e02\u0e31\u0e49\u0e19\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22\u0e19\u0e35\u0e49 \u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22\u0e17\u0e35\u0e48\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e08\u0e32\u0e01\u0e04\u0e48\u0e32\u0e41\u0e25\u0e21\u0e1a\u0e4c\u0e14\u0e32\u0e17\u0e35\u0e48\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14\u0e44\u0e14\u0e49<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e0a\u0e49\u0e23\u0e2b\u0e31\u0e2a\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e19\u0e35\u0e49\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e04\u0e48\u0e32\u0e2a\u0e31\u0e21\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e19\u0e35\u0e49:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#find coefficients of best model\n<\/span>best_model &lt;- glmnet(x, y, alpha = <span style=\"color: #008000;\">1<\/span> , lambda = best_lambda)\ncoef(best_model)\n\n5 x 1 sparse Matrix of class \"dgCMatrix\"\n                   s0\n(Intercept) 484.20742\nmpg -2.95796\nwt 21.37988\ndrat.      \nqsec -19.43425<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">\u0e44\u0e21\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e04\u0e48\u0e32\u0e2a\u0e31\u0e21\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e15\u0e31\u0e27\u0e17\u0e33\u0e19\u0e32\u0e22 <strong>drat<\/strong> \u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso \u0e25\u0e14\u0e04\u0e48\u0e32\u0e2a\u0e31\u0e21\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e43\u0e2b\u0e49\u0e40\u0e1b\u0e47\u0e19\u0e28\u0e39\u0e19\u0e22\u0e4c \u0e0b\u0e36\u0e48\u0e07\u0e2b\u0e21\u0e32\u0e22\u0e04\u0e27\u0e32\u0e21\u0e27\u0e48\u0e32\u0e40\u0e02\u0e32\u0e16\u0e39\u0e01\u0e25\u0e1a\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e42\u0e21\u0e40\u0e14\u0e25\u0e42\u0e14\u0e22\u0e2a\u0e34\u0e49\u0e19\u0e40\u0e0a\u0e34\u0e07\u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01\u0e40\u0e02\u0e32\u0e44\u0e21\u0e48\u0e21\u0e35\u0e2d\u0e34\u0e17\u0e18\u0e34\u0e1e\u0e25\u0e40\u0e1e\u0e35\u0e22\u0e07\u0e1e\u0e2d<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e42\u0e1b\u0e23\u0e14\u0e17\u0e23\u0e32\u0e1a\u0e27\u0e48\u0e32\u0e19\u0e35\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e02\u0e49\u0e2d\u0e41\u0e15\u0e01\u0e15\u0e48\u0e32\u0e07\u0e17\u0e35\u0e48\u0e2a\u0e33\u0e04\u0e31\u0e0d\u0e23\u0e30\u0e2b\u0e27\u0e48\u0e32\u0e07 <a href=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e02\u0e2d\u0e07\u0e2a\u0e31\u0e19\u0e40\u0e02\u0e32\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e2a\u0e31\u0e19<\/a> \u0e41\u0e25\u0e30 <a href=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28<\/a> \u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e23\u0e34\u0e14\u0e08\u0e4c\u0e08\u0e30\u0e25\u0e14\u0e04\u0e48\u0e32\u0e2a\u0e31\u0e21\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14 <em>\u0e43\u0e2b\u0e49<\/em> \u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e28\u0e39\u0e19\u0e22\u0e4c \u0e41\u0e15\u0e48\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e21\u0e35\u0e28\u0e31\u0e01\u0e22\u0e20\u0e32\u0e1e\u0e43\u0e19\u0e01\u0e32\u0e23\u0e25\u0e1a\u0e15\u0e31\u0e27\u0e17\u0e33\u0e19\u0e32\u0e22\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e42\u0e14\u0e22\u0e01\u0e32\u0e23\u0e25\u0e14\u0e04\u0e48\u0e32\u0e2a\u0e31\u0e21\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e43\u0e2b\u0e49\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e28\u0e39\u0e19\u0e22\u0e4c <em>\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e2a\u0e21\u0e1a\u0e39\u0e23\u0e13\u0e4c<\/em><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e19\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e19\u0e35\u0e49\u0e40\u0e23\u0e32\u0e22\u0e31\u0e07\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e0a\u0e49\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso \u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e04\u0e32\u0e14\u0e01\u0e32\u0e23\u0e13\u0e4c\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e2a\u0e31\u0e07\u0e40\u0e01\u0e15\u0e43\u0e2b\u0e21\u0e48\u0e46 \u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e40\u0e0a\u0e48\u0e19 \u0e2a\u0e21\u0e21\u0e15\u0e34\u0e27\u0e48\u0e32\u0e40\u0e23\u0e32\u0e21\u0e35\u0e23\u0e16\u0e04\u0e31\u0e19\u0e43\u0e2b\u0e21\u0e48\u0e17\u0e35\u0e48\u0e21\u0e35\u0e04\u0e38\u0e13\u0e2a\u0e21\u0e1a\u0e31\u0e15\u0e34\u0e14\u0e31\u0e07\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e19\u0e35\u0e49:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">\u0e44\u0e21\u0e25\u0e4c\u0e15\u0e48\u0e2d\u0e41\u0e01\u0e25\u0e25\u0e2d\u0e19: 24<\/span><\/li>\n<li> <span style=\"color: #000000;\">\u0e19\u0e49\u0e33\u0e2b\u0e19\u0e31\u0e01: 2.5<\/span><\/li>\n<li> <span style=\"color: #000000;\">\u0e23\u0e32\u0e04\u0e32: 3.5<\/span><\/li>\n<li> <span style=\"color: #000000;\">\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35: 18.5<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">\u0e23\u0e2b\u0e31\u0e2a\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e19\u0e35\u0e49\u0e41\u0e2a\u0e14\u0e07\u0e27\u0e34\u0e18\u0e35\u0e43\u0e0a\u0e49\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e17\u0e33\u0e19\u0e32\u0e22\u0e04\u0e48\u0e32 <em>hp<\/em> \u0e02\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e31\u0e07\u0e40\u0e01\u0e15\u0e43\u0e2b\u0e21\u0e48\u0e19\u0e35\u0e49:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define new observation\n<\/span>new = matrix(c(24, 2.5, 3.5, 18.5), nrow= <span style=\"color: #008000;\">1<\/span> , ncol= <span style=\"color: #008000;\">4<\/span> ) \n\n<span style=\"color: #008080;\">#use lasso regression model to predict response value\n<\/span>predict(best_model, s = best_lambda, newx = new)\n\n[1,] 109.0842<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">\u0e08\u0e32\u0e01\u0e04\u0e48\u0e32\u0e17\u0e35\u0e48\u0e1b\u0e49\u0e2d\u0e19 \u0e42\u0e21\u0e40\u0e14\u0e25\u0e04\u0e32\u0e14\u0e01\u0e32\u0e23\u0e13\u0e4c\u0e27\u0e48\u0e32\u0e23\u0e16\u0e04\u0e31\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e21\u0e35\u0e04\u0e48\u0e32 <em>\u0e41\u0e23\u0e07\u0e21\u0e49\u0e32<\/em> \u0e2d\u0e22\u0e39\u0e48\u0e17\u0e35\u0e48 <strong>109.0842<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22\u0e19\u0e35\u0e49 \u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e04\u0e33\u0e19\u0e27\u0e13 <a href=\"https:\/\/statorials.org\/th\/\u0e04\u0e48\u0e32-r-\u0e01\u0e33\u0e25\u0e31\u0e07\u0e2a\u0e2d\u0e07\u0e17\u0e35\u0e48\u0e14\u0e35\/\" target=\"_blank\" rel=\"noopener noreferrer\">R-squared \u0e02\u0e2d\u0e07\u0e42\u0e21\u0e40\u0e14\u0e25<\/a> \u0e08\u0e32\u0e01\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e01\u0e32\u0e23\u0e1d\u0e36\u0e01\u0e44\u0e14\u0e49:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#use fitted best model to make predictions\n<\/span>y_predicted &lt;- <span style=\"color: #3366ff;\">predict<\/span> (best_model, s = best_lambda, newx = x)\n\n<span style=\"color: #008080;\">#find OHS and SSE<\/span>\nsst &lt;- <span style=\"color: #3366ff;\">sum<\/span> ((y - <span style=\"color: #3366ff;\">mean<\/span> (y))^2)\nsse &lt;- <span style=\"color: #3366ff;\">sum<\/span> ((y_predicted - y)^2)\n\n<span style=\"color: #008080;\">#find R-Squared\n<\/span>rsq &lt;- 1 - sse\/sst\nrsq\n\n[1] 0.8047064\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">R \u0e01\u0e33\u0e25\u0e31\u0e07\u0e2a\u0e2d\u0e07\u0e01\u0e25\u0e32\u0e22\u0e40\u0e1b\u0e47\u0e19 <strong>0.8047064<\/strong> \u0e19\u0e31\u0e48\u0e19\u0e04\u0e37\u0e2d\u0e41\u0e1a\u0e1a\u0e08\u0e33\u0e25\u0e2d\u0e07\u0e17\u0e35\u0e48\u0e14\u0e35\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e04\u0e27\u0e32\u0e21\u0e41\u0e1b\u0e23\u0e1c\u0e31\u0e19\u0e02\u0e2d\u0e07\u0e04\u0e48\u0e32\u0e15\u0e2d\u0e1a\u0e2a\u0e19\u0e2d\u0e07\u0e02\u0e2d\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e01\u0e32\u0e23\u0e1d\u0e36\u0e01\u0e2d\u0e1a\u0e23\u0e21 <strong>\u0e44\u0e14\u0e49 80.47%<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">\u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e04\u0e49\u0e19\u0e2b\u0e32\u0e42\u0e04\u0e49\u0e14 R \u0e41\u0e1a\u0e1a\u0e40\u0e15\u0e47\u0e21\u0e17\u0e35\u0e48\u0e43\u0e0a\u0e49\u0e43\u0e19\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e19\u0e35\u0e49 <a href=\"https:\/\/github.com\/Statorials\/R-Guides\/blob\/main\/lasso_regression.R\" target=\"_blank\" rel=\"noopener noreferrer\">\u0e44\u0e14\u0e49 \u0e17\u0e35\u0e48\u0e19\u0e35\u0e48<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a Lasso \u0e40\u0e1b\u0e47\u0e19\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e0a\u0e49\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e1e\u0e2d\u0e14 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-3"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Lasso Regression \u0e43\u0e19 R (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)<\/title>\n<meta name=\"description\" content=\"\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\" \/>\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\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a-lasso-\u0e43\u0e19-r\/\" \/>\n<meta property=\"og:locale\" content=\"th_TH\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Lasso Regression \u0e43\u0e19 R (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)\" \/>\n<meta property=\"og:description\" content=\"\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a-lasso-\u0e43\u0e19-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T07:56:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/lassor1.png\" \/>\n<meta name=\"author\" content=\"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u0e19\u0e32\u0e17\u0e35\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/\",\"url\":\"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/\",\"name\":\"Lasso Regression \u0e43\u0e19 R (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/th\/#website\"},\"datePublished\":\"2023-07-27T07:56:18+00:00\",\"dateModified\":\"2023-07-27T07:56:18+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/th\/#\/schema\/person\/7c9bb3d0f799d0f1b17883495e1de332\"},\"description\":\"\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/#breadcrumb\"},\"inLanguage\":\"th\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0e1a\u0e49\u0e32\u0e19\",\"item\":\"https:\/\/statorials.org\/th\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lasso regression \u0e43\u0e19 r (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/th\/#website\",\"url\":\"https:\/\/statorials.org\/th\/\",\"name\":\"Statorials\",\"description\":\"\u0e04\u0e33\u0e41\u0e19\u0e30\u0e19\u0e33\u0e02\u0e2d\u0e07\u0e04\u0e38\u0e13\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e17\u0e32\u0e07\u0e2a\u0e16\u0e34\u0e15\u0e34!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/th\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"th\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/th\/#\/schema\/person\/7c9bb3d0f799d0f1b17883495e1de332\",\"name\":\"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"th\",\"@id\":\"https:\/\/statorials.org\/th\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/th\/wp-content\/uploads\/2023\/11\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/th\/wp-content\/uploads\/2023\/11\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19\"},\"description\":\"\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35 \u0e09\u0e31\u0e19\u0e0a\u0e37\u0e48\u0e2d\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e28\u0e32\u0e2a\u0e15\u0e23\u0e32\u0e08\u0e32\u0e23\u0e22\u0e4c\u0e2a\u0e16\u0e34\u0e15\u0e34\u0e40\u0e01\u0e29\u0e35\u0e22\u0e13\u0e2d\u0e32\u0e22\u0e38\u0e41\u0e25\u0e49\u0e27 \u0e41\u0e25\u0e30\u0e1c\u0e31\u0e19\u0e15\u0e31\u0e27\u0e21\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e23\u0e39\u0e2a\u0e2d\u0e19\u0e2a\u0e16\u0e34\u0e15\u0e34\u0e42\u0e14\u0e22\u0e40\u0e09\u0e1e\u0e32\u0e30 \u0e14\u0e49\u0e27\u0e22\u0e1b\u0e23\u0e30\u0e2a\u0e1a\u0e01\u0e32\u0e23\u0e13\u0e4c\u0e41\u0e25\u0e30\u0e04\u0e27\u0e32\u0e21\u0e40\u0e0a\u0e35\u0e48\u0e22\u0e27\u0e0a\u0e32\u0e0d\u0e17\u0e35\u0e48\u0e01\u0e27\u0e49\u0e32\u0e07\u0e02\u0e27\u0e32\u0e07\u0e43\u0e19\u0e2a\u0e32\u0e02\u0e32\u0e2a\u0e16\u0e34\u0e15\u0e34 \u0e09\u0e31\u0e19\u0e01\u0e23\u0e30\u0e15\u0e37\u0e2d\u0e23\u0e37\u0e2d\u0e23\u0e49\u0e19\u0e17\u0e35\u0e48\u0e08\u0e30\u0e41\u0e1a\u0e48\u0e07\u0e1b\u0e31\u0e19\u0e04\u0e27\u0e32\u0e21\u0e23\u0e39\u0e49\u0e02\u0e2d\u0e07\u0e09\u0e31\u0e19\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e2a\u0e23\u0e34\u0e21\u0e28\u0e31\u0e01\u0e22\u0e20\u0e32\u0e1e\u0e19\u0e31\u0e01\u0e40\u0e23\u0e35\u0e22\u0e19\u0e1c\u0e48\u0e32\u0e19 Statorials. \u0e23\u0e39\u0e49\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21\",\"sameAs\":[\"https:\/\/statorials.org\/th\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Lasso Regression \u0e43\u0e19 R (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)","description":"\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19","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\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a-lasso-\u0e43\u0e19-r\/","og_locale":"th_TH","og_type":"article","og_title":"Lasso Regression \u0e43\u0e19 R (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)","og_description":"\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19","og_url":"https:\/\/statorials.org\/th\/\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a-lasso-\u0e43\u0e19-r\/","og_site_name":"Statorials","article_published_time":"2023-07-27T07:56:18+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/lassor1.png"}],"author":"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19","twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19","Est. reading time":"1 \u0e19\u0e32\u0e17\u0e35"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/","url":"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/","name":"Lasso Regression \u0e43\u0e19 R (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)","isPartOf":{"@id":"https:\/\/statorials.org\/th\/#website"},"datePublished":"2023-07-27T07:56:18+00:00","dateModified":"2023-07-27T07:56:18+00:00","author":{"@id":"https:\/\/statorials.org\/th\/#\/schema\/person\/7c9bb3d0f799d0f1b17883495e1de332"},"description":"\u0e1a\u0e17\u0e0a\u0e48\u0e27\u0e22\u0e2a\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e16\u0e14\u0e16\u0e2d\u0e22\u0e41\u0e1a\u0e1a\u0e1a\u0e48\u0e27\u0e07\u0e1a\u0e32\u0e28\u0e43\u0e19 R \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19","breadcrumb":{"@id":"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/#breadcrumb"},"inLanguage":"th","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/th\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%96%e0%b8%94%e0%b8%96%e0%b8%ad%e0%b8%a2%e0%b9%81%e0%b8%9a%e0%b8%9a-lasso-%e0%b9%83%e0%b8%99-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0e1a\u0e49\u0e32\u0e19","item":"https:\/\/statorials.org\/th\/"},{"@type":"ListItem","position":2,"name":"Lasso regression \u0e43\u0e19 r (\u0e17\u0e35\u0e25\u0e30\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/th\/#website","url":"https:\/\/statorials.org\/th\/","name":"Statorials","description":"\u0e04\u0e33\u0e41\u0e19\u0e30\u0e19\u0e33\u0e02\u0e2d\u0e07\u0e04\u0e38\u0e13\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e17\u0e32\u0e07\u0e2a\u0e16\u0e34\u0e15\u0e34!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/th\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"th"},{"@type":"Person","@id":"https:\/\/statorials.org\/th\/#\/schema\/person\/7c9bb3d0f799d0f1b17883495e1de332","name":"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19","image":{"@type":"ImageObject","inLanguage":"th","@id":"https:\/\/statorials.org\/th\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/th\/wp-content\/uploads\/2023\/11\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/th\/wp-content\/uploads\/2023\/11\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"\u0e14\u0e23.\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e41\u0e2d\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e2a\u0e31\u0e19"},"description":"\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35 \u0e09\u0e31\u0e19\u0e0a\u0e37\u0e48\u0e2d\u0e40\u0e1a\u0e19\u0e08\u0e32\u0e21\u0e34\u0e19 \u0e28\u0e32\u0e2a\u0e15\u0e23\u0e32\u0e08\u0e32\u0e23\u0e22\u0e4c\u0e2a\u0e16\u0e34\u0e15\u0e34\u0e40\u0e01\u0e29\u0e35\u0e22\u0e13\u0e2d\u0e32\u0e22\u0e38\u0e41\u0e25\u0e49\u0e27 \u0e41\u0e25\u0e30\u0e1c\u0e31\u0e19\u0e15\u0e31\u0e27\u0e21\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e23\u0e39\u0e2a\u0e2d\u0e19\u0e2a\u0e16\u0e34\u0e15\u0e34\u0e42\u0e14\u0e22\u0e40\u0e09\u0e1e\u0e32\u0e30 \u0e14\u0e49\u0e27\u0e22\u0e1b\u0e23\u0e30\u0e2a\u0e1a\u0e01\u0e32\u0e23\u0e13\u0e4c\u0e41\u0e25\u0e30\u0e04\u0e27\u0e32\u0e21\u0e40\u0e0a\u0e35\u0e48\u0e22\u0e27\u0e0a\u0e32\u0e0d\u0e17\u0e35\u0e48\u0e01\u0e27\u0e49\u0e32\u0e07\u0e02\u0e27\u0e32\u0e07\u0e43\u0e19\u0e2a\u0e32\u0e02\u0e32\u0e2a\u0e16\u0e34\u0e15\u0e34 \u0e09\u0e31\u0e19\u0e01\u0e23\u0e30\u0e15\u0e37\u0e2d\u0e23\u0e37\u0e2d\u0e23\u0e49\u0e19\u0e17\u0e35\u0e48\u0e08\u0e30\u0e41\u0e1a\u0e48\u0e07\u0e1b\u0e31\u0e19\u0e04\u0e27\u0e32\u0e21\u0e23\u0e39\u0e49\u0e02\u0e2d\u0e07\u0e09\u0e31\u0e19\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e2a\u0e23\u0e34\u0e21\u0e28\u0e31\u0e01\u0e22\u0e20\u0e32\u0e1e\u0e19\u0e31\u0e01\u0e40\u0e23\u0e35\u0e22\u0e19\u0e1c\u0e48\u0e32\u0e19 Statorials. \u0e23\u0e39\u0e49\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21","sameAs":["https:\/\/statorials.org\/th"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/posts\/1198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/comments?post=1198"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/posts\/1198\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/media?parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/categories?post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/th\/wp-json\/wp\/v2\/tags?post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}