{"id":3791,"date":"2023-07-15T12:43:29","date_gmt":"2023-07-15T12:43:29","guid":{"rendered":"https:\/\/statorials.org\/de\/restgraph-ggplot2\/"},"modified":"2023-07-15T12:43:29","modified_gmt":"2023-07-15T12:43:29","slug":"restgraph-ggplot2","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/restgraph-ggplot2\/","title":{"rendered":"So erstellen sie ein restdiagramm in ggplot2 (mit beispiel)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Mithilfe <strong>von Residuendiagrammen<\/strong> wird beurteilt, ob die <a href=\"https:\/\/statorials.org\/de\/ruckstand\/\" target=\"_blank\" rel=\"noopener\">Residuen<\/a> eines Regressionsmodells normalverteilt sind und ob sie <a href=\"https:\/\/statorials.org\/de\/heteroskedastizitatsregression\/\" target=\"_blank\" rel=\"noopener\">Heteroskedastizit\u00e4t<\/a> aufweisen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Um ein Residuendiagramm in ggplot2 zu erstellen, k\u00f6nnen Sie die folgende grundlegende Syntax verwenden:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\nggplot(model, aes(x = .fitted, y = .resid)) +\n  geom_point() +\n  geom_hline(yintercept = <span style=\"color: #008000;\">0<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Das folgende Beispiel zeigt, wie diese Syntax in der Praxis verwendet wird.<\/span><\/p>\n<h2> <strong>Beispiel: Erstellen eines Restdiagramms in ggplot2<\/strong><\/h2>\n<p> <span style=\"color: #000000;\">F\u00fcr dieses Beispiel verwenden wir den in R integrierten <a href=\"https:\/\/statorials.org\/de\/mtcars-r-datensatz\/\" target=\"_blank\" rel=\"noopener\">mtcars-<\/a> Datensatz:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view first six rows of mtcars dataset<\/span>\nhead(mtcars)\n                   mpg cyl disp hp drat wt qsec vs am gear carb\nMazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4\nMazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4\nDatsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1\nHornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1\nHornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2\nValiant 18.1 6 225 105 2.76 3,460 20.22 1 0 3 1<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Zuerst passen wir ein Regressionsmodell an, wobei wir <strong>mpg<\/strong> als Antwortvariable und <b>qsec<\/b> als Pr\u00e4diktorvariable verwenden:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#fit regression model<\/span>\nmodel &lt;- lm(mpg ~ qsec, data=mtcars)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Als N\u00e4chstes verwenden wir die folgende Syntax, um ein Residuendiagramm in ggplot2 zu erstellen:<\/span> <\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#create residual plot\n<\/span>ggplot(model, aes(x = .fitted, y = .resid)) +\n  geom_point() +\n  geom_hline(yintercept = <span style=\"color: #008000;\">0<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-30786\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ajustement1.jpg\" alt=\"Restdiagramm in ggplot2\" width=\"569\" height=\"440\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Die x-Achse zeigt die angepassten Werte und die y-Achse zeigt die Residuen an.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Die Residuen scheinen ohne klares Muster zuf\u00e4llig um Null herum verstreut zu sein, was darauf hindeutet, dass die Annahme der Homoskedastizit\u00e4t erf\u00fcllt ist.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Mit anderen Worten: Die <a href=\"https:\/\/statorials.org\/de\/wie-man-regressionskoeffizienten-interpretiert\/\" target=\"_blank\" rel=\"noopener\">Koeffizienten<\/a> des Regressionsmodells sollten zuverl\u00e4ssig sein und wir m\u00fcssen keine <a href=\"https:\/\/statorials.org\/de\/daten-in-r-umwandeln\/\" target=\"_blank\" rel=\"noopener\">Transformation<\/a> der Daten durchf\u00fchren.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Beachten Sie auch, dass wir die Funktion <strong>labs()<\/strong> verwenden k\u00f6nnten, um dem Restplot einen Titel und Achsenbeschriftungen hinzuzuf\u00fcgen:<\/span> <\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#create residual plot with title and axis labels\n<\/span>ggplot(model, aes(x = .fitted, y = .resid)) +\n  geom_point() +\n  geom_hline(yintercept = <span style=\"color: #008000;\">0<\/span> ) +\n  labs(title=' <span style=\"color: #ff0000;\">Residual vs. Fitted Values Plot<\/span> ', x=' <span style=\"color: #ff0000;\">Fitted Values<\/span> ', y=' <span style=\"color: #ff0000;\">Residuals<\/span> ')<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-30787\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ajustement2.jpg\" alt=\"ggplot2 zeichnet Residuen gegen\u00fcber angepassten Werten mit Achsenbeschriftungen auf\" width=\"532\" height=\"406\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In den folgenden Tutorials wird erl\u00e4utert, wie Sie andere h\u00e4ufige Aufgaben in R ausf\u00fchren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/ruckstande-standardisiert-in-r\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie standardisierte Residuen in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/reste-in-r-studentisiert\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie studentisierte Residuen in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/histogramm-der-residuen-in-r\/\" target=\"_blank\" rel=\"noopener\">So erstellen Sie ein Histogramm von Residuen in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mithilfe von Residuendiagrammen wird beurteilt, ob die Residuen eines Regressionsmodells normalverteilt sind und ob sie Heteroskedastizit\u00e4t aufweisen. Um ein Residuendiagramm in ggplot2 zu erstellen, k\u00f6nnen Sie die folgende grundlegende Syntax verwenden: library (ggplot2) ggplot(model, aes(x = .fitted, y = .resid)) + geom_point() + geom_hline(yintercept = 0 ) Das folgende Beispiel zeigt, wie diese Syntax in [&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 erstellen Sie ein Restdiagramm in ggplot2 (mit Beispiel) \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Residuendiagramm in ggplot2 erstellt wird.\" \/>\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\/restgraph-ggplot2\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So erstellen Sie ein Restdiagramm in ggplot2 (mit Beispiel) \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Residuendiagramm in ggplot2 erstellt wird.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/restgraph-ggplot2\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-15T12:43:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ajustement1.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\/restgraph-ggplot2\/\",\"url\":\"https:\/\/statorials.org\/de\/restgraph-ggplot2\/\",\"name\":\"So erstellen Sie ein Restdiagramm in ggplot2 (mit Beispiel) \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-15T12:43:29+00:00\",\"dateModified\":\"2023-07-15T12:43:29+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Residuendiagramm in ggplot2 erstellt wird.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/restgraph-ggplot2\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/restgraph-ggplot2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/restgraph-ggplot2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So erstellen sie ein restdiagramm in ggplot2 (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 erstellen Sie ein Restdiagramm in ggplot2 (mit Beispiel) \u2013 Statorials","description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Residuendiagramm in ggplot2 erstellt wird.","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\/restgraph-ggplot2\/","og_locale":"de_DE","og_type":"article","og_title":"So erstellen Sie ein Restdiagramm in ggplot2 (mit Beispiel) \u2013 Statorials","og_description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Residuendiagramm in ggplot2 erstellt wird.","og_url":"https:\/\/statorials.org\/de\/restgraph-ggplot2\/","og_site_name":"Statorials","article_published_time":"2023-07-15T12:43:29+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ajustement1.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\/restgraph-ggplot2\/","url":"https:\/\/statorials.org\/de\/restgraph-ggplot2\/","name":"So erstellen Sie ein Restdiagramm in ggplot2 (mit Beispiel) \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-15T12:43:29+00:00","dateModified":"2023-07-15T12:43:29+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Residuendiagramm in ggplot2 erstellt wird.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/restgraph-ggplot2\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/restgraph-ggplot2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/restgraph-ggplot2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So erstellen sie ein restdiagramm in ggplot2 (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\/3791"}],"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=3791"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3791\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=3791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=3791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=3791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}