{"id":3150,"date":"2023-07-18T23:26:33","date_gmt":"2023-07-18T23:26:33","guid":{"rendered":"https:\/\/statorials.org\/de\/lossregression-in-r\/"},"modified":"2023-07-18T23:26:33","modified_gmt":"2023-07-18T23:26:33","slug":"lossregression-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/lossregression-in-r\/","title":{"rendered":"So f\u00fchren sie eine loess-regression in r durch (mit beispiel)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><strong>Die LOESS-Regression<\/strong> , manchmal auch lokale Regression genannt, ist eine Methode, die lokale Anpassungen verwendet, um ein Regressionsmodell an einen Datensatz anzupassen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Das folgende Schritt-f\u00fcr-Schritt-Beispiel zeigt, wie eine LOESS-Regression in R durchgef\u00fchrt wird.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 1: Erstellen Sie die Daten<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Erstellen wir zun\u00e4chst den folgenden Datenrahmen in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view DataFrame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (x=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),\n                 y=c(1, 4, 7, 13, 19, 24, 20, 15, 13, 11, 15, 18, 22, 27))\n\n<span style=\"color: #008080;\">#view first six rows of data frame<\/span>\nhead(df)\n\n  xy\n1 1 1\n2 2 4\n3 3 7\n4 4 13\n5 5 19\n6 6 24\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 2: Passen Sie mehrere LOESS-Regressionsmodelle an<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen die Funktion <strong>loess()<\/strong> verwenden, um mehrere LOESS-Regressionsmodelle an diesen Datensatz anzupassen, indem wir unterschiedliche Werte f\u00fcr den <strong>Span-<\/strong> Parameter verwenden:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#fit several LOESS regression models to dataset\n<\/span>loess50 &lt;- loess(y ~ x, data=df, span= <span style=\"color: #008000;\">.5<\/span> )\nsmooth50 &lt;- predict(loess50) \n\nloess75 &lt;- loess(y ~ x, data=df, span= <span style=\"color: #008000;\">.75<\/span> )\nsmooth75 &lt;- predict(loess75) \n\nloess90 &lt;- loess(y ~ x, data=df, span= <span style=\"color: #008000;\">.9<\/span> )\nsmooth90 &lt;- predict(loess90) \n\n<span style=\"color: #008080;\">#create scatterplot with each regression line overlaid\n<\/span>plot(df$x, df$y, pch= <span style=\"color: #008000;\">19<\/span> , main=' <span style=\"color: #ff0000;\">Loess Regression Models<\/span> ')\nlines(smooth50, x=df$x, col=' <span style=\"color: #ff0000;\">red<\/span> ')\nlines(smooth75, x=df$x, col=' <span style=\"color: #ff0000;\">purple<\/span> ')\nlines(smooth90, x=df$x, col=' <span style=\"color: #ff0000;\">blue<\/span> ')\nlegend(' <span style=\"color: #ff0000;\">bottomright<\/span> ', legend=c(' <span style=\"color: #ff0000;\">.5<\/span> ', ' <span style=\"color: #ff0000;\">.75<\/span> ', ' <span style=\"color: #ff0000;\">.9<\/span> '),\n        col=c(' <span style=\"color: #ff0000;\">red<\/span> ', ' <span style=\"color: #ff0000;\">purple<\/span> ', ' <span style=\"color: #ff0000;\">blue<\/span> '), pch= <span style=\"color: #008000;\">19<\/span> , title=' <span style=\"color: #ff0000;\">Smoothing Span<\/span> ')\n<\/strong><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-26784\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loess1.jpg\" alt=\"L\u00f6ss-Regression in R\" width=\"452\" height=\"447\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass das Regressionsmodell umso weniger \u201eglatt\u201c ist und umso mehr versucht, die Datenpunkte anzupassen, je niedriger der Wert ist, den wir f\u00fcr <strong>span<\/strong> verwenden.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 3: Verwenden Sie die K-Fold-Kreuzvalidierung, um das beste Modell zu finden<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Um den optimalen zu verwendenden <strong>Extent-<\/strong> Wert zu finden, k\u00f6nnen wir mithilfe der Funktionen im <strong>Caret-<\/strong> Paket <a href=\"https:\/\/statorials.org\/de\/k-fache-kreuzvalidierung\/\" target=\"_blank\" rel=\"noopener\">eine k-fache Kreuzvalidierung<\/a> durchf\u00fchren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (caret)\n\n<span style=\"color: #008080;\">#define k-fold cross validation method\n<\/span>ctrl &lt;- trainControl(method = \" <span style=\"color: #ff0000;\">cv<\/span> \", number = <span style=\"color: #008000;\">5<\/span> )\ngrid &lt;- expand. <span style=\"color: #3366ff;\">grid<\/span> (span = seq( <span style=\"color: #008000;\">0.5<\/span> , <span style=\"color: #008000;\">0.9<\/span> , len = <span style=\"color: #008000;\">5<\/span> ), degree = <span style=\"color: #008000;\">1<\/span> )\n\n<span style=\"color: #008080;\">#perform cross-validation using smoothing spans ranging from 0.5 to 0.9\n<\/span>model &lt;- train(y ~ x, data = df, method = \" <span style=\"color: #ff0000;\">gamLoess<\/span> \", tuneGrid=grid, trControl = ctrl)\n\n<span style=\"color: #008080;\">#print results of k-fold cross-validation\n<\/span><span style=\"color: #008000;\">print<\/span> (model)\n\n14 samples\n 1 predictor\n\nNo pre-processing\nResampling: Cross-Validated (5 fold) \nSummary of sample sizes: 12, 11, 11, 11, 11 \nResampling results across tuning parameters:\n\n  span RMSE Rsquared MAE      \n  0.5 10.148315 0.9570137 6.467066\n  0.6 7.854113 0.9350278 5.343473\n  0.7 6.113610 0.8150066 4.769545\n  0.8 17.814105 0.8202561 11.875943\n  0.9 26.705626 0.7384931 17.304833\n\nTuning parameter 'degree' was held constant at a value of 1\nRMSE was used to select the optimal model using the smallest value.\nThe final values used for the model were span = 0.7 and degree = 1.<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen sehen, dass der <strong>Spannenwert<\/strong> , der den niedrigsten Wert f\u00fcr <a href=\"https:\/\/statorials.org\/de\/wie-man-rmse-interpretiert\/\" target=\"_blank\" rel=\"noopener\">den quadratischen Mittelfehler<\/a> (RMSE) ergab, <strong>0,7<\/strong> betr\u00e4gt.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Daher w\u00fcrden wir f\u00fcr unser endg\u00fcltiges LOESS-Regressionsmodell einen Wert von <strong>0,7<\/strong> f\u00fcr das <strong>Span-<\/strong> Argument in der Funktion <strong>loess()<\/strong> verwenden.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Die folgenden Tutorials bieten zus\u00e4tzliche Informationen zu Regressionsmodellen in R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/einfache-lineare-regression-in-r\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine einfache lineare Regression in R durch<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/multiple-lineare-regression-r\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine multiple lineare Regression in R durch<\/a><br \/> So f\u00fchren Sie eine logistische Regression in R durch<br \/> <a href=\"https:\/\/statorials.org\/de\/quantilregression-in-r\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine Quantilregression in R durch<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/gewichtete-kleinste-quadrate-in-r\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine gewichtete Regression in R durch<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Die LOESS-Regression , manchmal auch lokale Regression genannt, ist eine Methode, die lokale Anpassungen verwendet, um ein Regressionsmodell an einen Datensatz anzupassen. Das folgende Schritt-f\u00fcr-Schritt-Beispiel zeigt, wie eine LOESS-Regression in R durchgef\u00fchrt wird. Schritt 1: Erstellen Sie die Daten Erstellen wir zun\u00e4chst den folgenden Datenrahmen in R: #view DataFrame df &lt;- data. frame (x=c(1, 2, [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>So f\u00fchren Sie eine LOESS-Regression in R durch (mit Beispiel) \u2013 Statistik<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird erl\u00e4utert, wie eine L\u00f6ss-Regression in R durchgef\u00fchrt wird, einschlie\u00dflich eines vollst\u00e4ndigen Beispiels.\" \/>\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\/de\/lossregression-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So f\u00fchren Sie eine LOESS-Regression in R durch (mit Beispiel) \u2013 Statistik\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird erl\u00e4utert, wie eine L\u00f6ss-Regression in R durchgef\u00fchrt wird, einschlie\u00dflich eines vollst\u00e4ndigen Beispiels.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/lossregression-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T23:26:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loess1.jpg\" \/>\n<meta name=\"author\" content=\"Dr. Benjamin Anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. Benjamin Anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/lossregression-in-r\/\",\"url\":\"https:\/\/statorials.org\/de\/lossregression-in-r\/\",\"name\":\"So f\u00fchren Sie eine LOESS-Regression in R durch (mit Beispiel) \u2013 Statistik\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-18T23:26:33+00:00\",\"dateModified\":\"2023-07-18T23:26:33+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird erl\u00e4utert, wie eine L\u00f6ss-Regression in R durchgef\u00fchrt wird, einschlie\u00dflich eines vollst\u00e4ndigen Beispiels.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/lossregression-in-r\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/lossregression-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/lossregression-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So f\u00fchren sie eine loess-regression in r durch (mit beispiel)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/de\/#website\",\"url\":\"https:\/\/statorials.org\/de\/\",\"name\":\"Statorials\",\"description\":\"Ihr Leitfaden f\u00fcr statistische Kompetenz !\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de-DE\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\",\"name\":\"Dr. Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-DE\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. Benjamin Anderson\"},\"description\":\"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen\",\"sameAs\":[\"https:\/\/statorials.org\/de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"So f\u00fchren Sie eine LOESS-Regression in R durch (mit Beispiel) \u2013 Statistik","description":"In diesem Tutorial wird erl\u00e4utert, wie eine L\u00f6ss-Regression in R durchgef\u00fchrt wird, einschlie\u00dflich eines vollst\u00e4ndigen Beispiels.","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\/de\/lossregression-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"So f\u00fchren Sie eine LOESS-Regression in R durch (mit Beispiel) \u2013 Statistik","og_description":"In diesem Tutorial wird erl\u00e4utert, wie eine L\u00f6ss-Regression in R durchgef\u00fchrt wird, einschlie\u00dflich eines vollst\u00e4ndigen Beispiels.","og_url":"https:\/\/statorials.org\/de\/lossregression-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-18T23:26:33+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loess1.jpg"}],"author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"2 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/lossregression-in-r\/","url":"https:\/\/statorials.org\/de\/lossregression-in-r\/","name":"So f\u00fchren Sie eine LOESS-Regression in R durch (mit Beispiel) \u2013 Statistik","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-18T23:26:33+00:00","dateModified":"2023-07-18T23:26:33+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird erl\u00e4utert, wie eine L\u00f6ss-Regression in R durchgef\u00fchrt wird, einschlie\u00dflich eines vollst\u00e4ndigen Beispiels.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/lossregression-in-r\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/lossregression-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/lossregression-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So f\u00fchren sie eine loess-regression in r durch (mit beispiel)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/de\/#website","url":"https:\/\/statorials.org\/de\/","name":"Statorials","description":"Ihr Leitfaden f\u00fcr statistische Kompetenz !","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de-DE"},{"@type":"Person","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0","name":"Dr. Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"de-DE","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Dr. Benjamin Anderson"},"description":"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen","sameAs":["https:\/\/statorials.org\/de"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3150"}],"collection":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/comments?post=3150"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3150\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=3150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=3150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=3150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}