{"id":2949,"date":"2023-07-19T22:57:09","date_gmt":"2023-07-19T22:57:09","guid":{"rendered":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/"},"modified":"2023-07-19T22:57:09","modified_gmt":"2023-07-19T22:57:09","slug":"korrelationsmatrix-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/","title":{"rendered":"So erstellen sie eine korrelationsmatrix in r (4 beispiele)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><span style=\"color: #000000;\">Eine <a href=\"https:\/\/statorials.org\/de\/wie-man-eine-korrelationsmatrix-liest\/\" target=\"_blank\" rel=\"noopener\">Korrelationsmatrix<\/a> ist eine quadratische Tabelle, die die <a href=\"https:\/\/statorials.org\/de\/pearson-korrelationskoeffizient-1\/\" target=\"_blank\" rel=\"noopener\">Korrelationskoeffizienten<\/a> zwischen Variablen in einem Datensatz anzeigt.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">Es bietet eine schnelle M\u00f6glichkeit, die St\u00e4rke linearer Beziehungen zu verstehen, die zwischen Variablen in einem Datensatz bestehen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Es gibt vier g\u00e4ngige Methoden zum Erstellen einer Korrelationsmatrix in R:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: die Cor-Funktion (um eine einfache Matrix von Korrelationskoeffizienten zu erhalten)<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>cor(df)<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 2: die rcorr-Funktion (um die p-Werte der Korrelationskoeffizienten zu erhalten)<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (Hmisc)\n\nrcorr( <span style=\"color: #3366ff;\">as.matrix<\/span> (df))<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 3: die Corrplot-Funktion (zur Visualisierung der Korrelationsmatrix)<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (corplot)\n\ncorrplot(cor(df))\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 4: die ggcorrplot-Funktion (zur Visualisierung der Korrelationsmatrix)<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggcorrplot)\n\nggcorrplot(cor(df))<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Die folgenden Beispiele zeigen, wie jede Methode mit dem folgenden Datenrahmen in R verwendet wird:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (assists=c(4, 5, 5, 6, 7, 8, 8, 10),\n                 rebounds=c(12, 14, 13, 7, 8, 8, 9, 13),\n                 points=c(22, 24, 26, 26, 29, 32, 20, 14))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n  assists rebound points\n1 4 12 22\n2 5 14 24\n3 5 13 26\n4 6 7 26\n5 7 8 29\n6 8 8 32\n7 8 9 20\n8 10 13 14\n<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel 1: Die cor-Funktion<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Mit der R-Base-Funktion <strong>cor()<\/strong> k\u00f6nnen wir eine Korrelationsmatrix erstellen, die die Korrelationskoeffizienten zwischen den einzelnen Variablen in unserem Datenrahmen anzeigt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#create correlation matrix<\/span>\ncor(df)\n\n            assists rebound points\nassists 1.0000000 -0.2448608 -0.3295730\nrebounds -0.2448608 1.0000000 -0.5220917\npoints -0.3295730 -0.5220917 1.0000000\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Die Korrelationskoeffizienten entlang der Diagonalen der Tabelle sind alle gleich 1, da jede Variable perfekt mit sich selbst korreliert.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Alle anderen Korrelationskoeffizienten geben die Korrelation zwischen verschiedenen paarweisen Kombinationen von Variablen an. Zum Beispiel:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Der Korrelationskoeffizient zwischen Assists und Rebounds betr\u00e4gt <strong>-0,245<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Der Korrelationskoeffizient zwischen Assists und Punkten betr\u00e4gt <strong>-0,330<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Der Korrelationskoeffizient zwischen Rebounds und Punkten betr\u00e4gt <strong>-0,522<\/strong> .<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel 2: die rcorr-Funktion<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen die Funktion <strong>rcorr()<\/strong> aus dem <strong>Hmisc-<\/strong> Paket in R verwenden, um eine Korrelationsmatrix zu erstellen, die die Korrelationskoeffizienten zwischen jeder Variablen in unserem Datenrahmen zeigt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (Hmisc)\n\n<span style=\"color: #008080;\">#create matrix of correlation coefficients and p-values<\/span>\nrcorr( <span style=\"color: #3366ff;\">as.matrix<\/span> (df))\n\n         assists rebound points\nassists 1.00 -0.24 -0.33\nrebounds -0.24 1.00 -0.52\npoints -0.33 -0.52 1.00\n\nn=8 \n\nP\n         assists rebound points\nassists 0.5589 0.4253\nrebounds 0.5589 0.1844\npoints 0.4253 0.1844<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Die erste Matrix zeigt die Korrelationskoeffizienten zwischen den Variablen und die zweite Matrix zeigt die entsprechenden p-Werte.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Beispielsweise betr\u00e4gt der Korrelationskoeffizient zwischen Assists und Rebounds <strong>-0,24<\/strong> und der p-Wert dieses Korrelationskoeffizienten betr\u00e4gt <strong>0,5589<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dies sagt uns, dass die Korrelation zwischen den beiden Variablen negativ ist, aber es handelt sich nicht um eine statistisch signifikante Korrelation, da der p-Wert nicht weniger als 0,05 betr\u00e4gt.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel 3: Die corrplot-Funktion<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen die Funktion <strong>corrplot()<\/strong> aus dem Paket <strong>corrplot<\/strong> in R verwenden, um die Korrelationsmatrix zu visualisieren:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (corplot)\n\n<span style=\"color: #008080;\">#visualize correlation matrix<\/span>\ncorrplot(cor(df))\n<\/strong><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25594 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/corrplot1.jpg\" alt=\"\" width=\"363\" height=\"333\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Die Farbe und Gr\u00f6\u00dfe der Kreise in der Korrelationsmatrix helfen uns, die Korrelationen zwischen den einzelnen Variablen zu visualisieren.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Beispielsweise ist der Kreis, in dem sich die Assists- und Rebounds-Variablen schneiden, klein und hellrot, was uns sagt, dass die Korrelation schwach und negativ ist.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel 4: Die corrplot-Funktion<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen die Funktion <strong>ggcorrplot()<\/strong> aus dem Paket <strong>ggcorrplot<\/strong> in R verwenden, um die Korrelationsmatrix zu visualisieren:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggcorrplot)\n\n<span style=\"color: #008080;\">#visualize correlation matrix<\/span>\nggcorrplot(cor(df))\n<\/strong><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25595 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/corrplot2.jpg\" alt=\"\" width=\"429\" height=\"369\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Die Farbe der Quadrate in der Korrelationsmatrix hilft uns, die Korrelationen zwischen den einzelnen Variablen zu visualisieren.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Die folgenden Tutorials erkl\u00e4ren, wie Sie andere h\u00e4ufige Aufgaben in R ausf\u00fchren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/spearman-korrelation-in-r\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie die Spearman-Rangkorrelation in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/teilkorrelation-r\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie die partielle Korrelation in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/rollierende-korrelation-in-r\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie die gleitende Korrelation in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eine Korrelationsmatrix ist eine quadratische Tabelle, die die Korrelationskoeffizienten zwischen Variablen in einem Datensatz anzeigt. Es bietet eine schnelle M\u00f6glichkeit, die St\u00e4rke linearer Beziehungen zu verstehen, die zwischen Variablen in einem Datensatz bestehen. Es gibt vier g\u00e4ngige Methoden zum Erstellen einer Korrelationsmatrix in R: Methode 1: die Cor-Funktion (um eine einfache Matrix von Korrelationskoeffizienten zu [&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 eine Korrelationsmatrix in R (4 Beispiele) \u2013 Statistik<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine Korrelationsmatrix in R 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\/korrelationsmatrix-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So erstellen Sie eine Korrelationsmatrix in R (4 Beispiele) \u2013 Statistik\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine Korrelationsmatrix in R erstellt wird.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T22:57:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/corrplot1.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=\"3 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/\",\"url\":\"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/\",\"name\":\"So erstellen Sie eine Korrelationsmatrix in R (4 Beispiele) \u2013 Statistik\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-19T22:57:09+00:00\",\"dateModified\":\"2023-07-19T22:57:09+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine Korrelationsmatrix in R erstellt wird.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So erstellen sie eine korrelationsmatrix in r (4 beispiele)\"}]},{\"@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 eine Korrelationsmatrix in R (4 Beispiele) \u2013 Statistik","description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine Korrelationsmatrix in R 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\/korrelationsmatrix-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"So erstellen Sie eine Korrelationsmatrix in R (4 Beispiele) \u2013 Statistik","og_description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine Korrelationsmatrix in R erstellt wird.","og_url":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-19T22:57:09+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/corrplot1.jpg"}],"author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"3 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/","url":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/","name":"So erstellen Sie eine Korrelationsmatrix in R (4 Beispiele) \u2013 Statistik","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-19T22:57:09+00:00","dateModified":"2023-07-19T22:57:09+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie eine Korrelationsmatrix in R erstellt wird.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/korrelationsmatrix-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So erstellen sie eine korrelationsmatrix in r (4 beispiele)"}]},{"@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\/2949"}],"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=2949"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/2949\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=2949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=2949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=2949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}