{"id":915,"date":"2023-07-28T07:59:26","date_gmt":"2023-07-28T07:59:26","guid":{"rendered":"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/"},"modified":"2023-07-28T07:59:26","modified_gmt":"2023-07-28T07:59:26","slug":"mahalanobis-abstand-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/","title":{"rendered":"So berechnen sie den mahalanobis-abstand in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Der <strong>Mahalanobis-Abstand<\/strong> ist der Abstand zwischen zwei Punkten in einem multivariaten Raum.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Es wird h\u00e4ufig verwendet, um Ausrei\u00dfer in statistischen Analysen mit mehreren Variablen zu erkennen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In diesem Tutorial wird erkl\u00e4rt, wie man den Mahalanobis-Abstand in R berechnet.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Beispiel: Mahalanobis-Distanz in R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Verwenden Sie die folgenden Schritte, um die Mahalanobis-Distanz f\u00fcr jede <a href=\"https:\/\/statorials.org\/de\/beobachtung-in-der-statistik\/\" target=\"_blank\" rel=\"noopener\">Beobachtung<\/a> in einem Datensatz in R zu berechnen.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Schritt 1: Erstellen Sie den Datensatz.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Zun\u00e4chst erstellen wir einen Datensatz, der die Pr\u00fcfungsergebnisse von 20 Studenten zusammen mit der Anzahl der Lernstunden, der Anzahl der von ihnen abgelegten \u00dcbungspr\u00fcfungen und ihrer aktuellen Note im Kurs anzeigt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data<\/span>\ndf = data.frame(score = c(91, 93, 72, 87, 86, 73, 68, 87, 78, 99, 95, 76, 84, 96, 76, 80, 83, 84, 73, 74) ,\n        hours = c(16, 6, 3, 1, 2, 3, 2, 5, 2, 5, 2, 3, 4, 3, 3, 3, 4, 3, 4, 4),\n        prep = c(3, 4, 0, 3, 4, 0, 1, 2, 1, 2, 3, 3, 3, 2, 2, 2, 3, 3, 2, 2),\n        grade = c(70, 88, 80, 83, 88, 84, 78, 94, 90, 93, 89, 82, 95, 94, 81, 93, 93, 90, 89, 89))\n\n<span style=\"color: #008080;\">#view first six rows of data\n<\/span>head(df)\n\n  score hours prep grade\n1 91 16 3 70\n2 93 6 4 88\n3 72 3 0 80\n4 87 1 3 83\n5 86 2 4 88\n6 73 3 0 84\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Schritt 2: Berechnen Sie die Mahalanobis-Distanz f\u00fcr jede Beobachtung.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Als n\u00e4chstes verwenden wir die in R integrierte Funktion <a href=\"https:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/stats\/html\/mahalanobis.html\" target=\"_blank\" rel=\"noopener noreferrer\">mahalanobis()<\/a> , um die Mahalanobis-Distanz f\u00fcr jede Beobachtung zu berechnen, die die folgende Syntax verwendet:<\/span><\/p>\n<p> <strong><span style=\"color: #000000;\">Mahalanobis (x, Mitte, cov)<\/span><\/strong><\/p>\n<p> <span style=\"color: #000000;\">Gold:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>x:<\/strong> Datenmatrix<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>Mitte:<\/strong> Durchschnittsvektor der Verteilung<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>cov:<\/strong> Verteilungskovarianzmatrix<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie diese Funktion f\u00fcr unseren Datensatz implementiert wird:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate Mahalanobis distance for each observation<\/span>\nmahalanobis(df, colMeans(df), cov(df))\n\n [1] 16.5019630 2.6392864 4.8507973 5.2012612 3.8287341 4.0905633\n [7] 4.2836303 2.4198736 1.6519576 5.6578253 3.9658770 2.9350178\n[13] 2.8102109 4.3682945 1.5610165 1.4595069 2.0245748 0.7502536\n[19] 2.7351292 2.2642268\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Schritt 3: Berechnen Sie den p-Wert f\u00fcr jede Mahalanobis-Distanz.<\/strong><\/span> <\/p>\n<div id=\"mv-first-video\" class=\"mv-video-target mv-video__featured mv-video__optimized mv-video__embedded\" data-video-id=\"tmdycgxksxqpmqpu0vbx\" data-autoplay=\"true\" data-automobile=\"true\" data-muted=\"true\" data-sticky=\"true\" data-autoinsert=\"true\" data-disable-jsonld=\"true\" data-video-placement-inited=\"true\">\n<div id=\"mediavine-video__target-div__8330b88d-7ed9-463c-85d3-dc370a4c9ab3\" class=\"mediavine-video__target-div\">\n<div class=\"mediavine-video__root-container\">\n<div class=\"mediavine-video__placement-container mediavine-video__bottom mediavine-video__right mediavine-video__dark-theme\">\n<div class=\"mediavine-video__title-bar\">\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen sehen, dass einige Mahalanobis-Abst\u00e4nde viel gr\u00f6\u00dfer sind als andere.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Um festzustellen, ob eine der Entfernungen statistisch signifikant ist, m\u00fcssen wir ihre <a href=\"https:\/\/statorials.org\/de\/p-werte-statistische-signifikanz\/\" target=\"_blank\" rel=\"noopener\">p-Werte<\/a> berechnen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Der p-Wert f\u00fcr jede Distanz wird als p-Wert berechnet, der der Chi-Quadrat-Statistik der Mahalanobis-Distanz mit k-1 Freiheitsgraden entspricht, wobei k = Anzahl der Variablen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In diesem Fall verwenden wir also Freiheitsgrade von 4-1 = 3.<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create new column in data frame to hold Mahalanobis distances<\/span>\ndf$mahal &lt;- mahalanobis(df, colMeans(df), cov(df))\n\n<span style=\"color: #008080;\">#create new column in data frame to hold p-value for each Mahalanobis distance\n<\/span>df$p &lt;- <span style=\"color: #3366ff;\">pchisq<\/span> (df$mahal, df= <span style=\"color: #339966;\">3<\/span> , lower.tail=FALSE)\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   score hours prep grade mahal p\n1 91 16 3 70 16.5019630 0.0008945642\n2 93 6 4 88 2.6392864 0.4506437265\n3 72 3 0 80 4.8507973 0.1830542407\n4 87 1 3 83 5.2012612 0.1576392526\n5 86 2 4 88 3.8287341 0.2805615121\n6 73 3 0 84 4.0905633 0.2518495222\n7 68 2 1 78 4.2836303 0.2324211504\n8 87 5 2 94 2.4198736 0.4899458807\n9 78 2 1 90 1.6519576 0.6476670033\n10 99 5 2 93 5.6578253 0.1294978092\n11 95 2 3 89 3.9658770 0.2651724541\n12 76 3 3 82 2.9350178 0.4017530495\n13 84 4 3 95 2.8102109 0.4218217836\n14 96 3 2 94 4.3682945 0.2243432904\n15 76 3 2 81 1.5610165 0.6682610031\n16 80 3 2 93 1.4595069 0.6916471506\n17 83 4 3 93 2.0245748 0.5673218169\n18 84 3 3 90 0.7502536 0.8613248635\n19 73 4 2 89 2.7351292 0.4342904353\n20 74 4 2 89 2.2642268 0.5194087143\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Im Allgemeinen gilt ein p-Wert von <strong>weniger als 0,001<\/strong> als Ausrei\u00dfer.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen sehen, dass die erste Beobachtung ein Ausrei\u00dfer im Datensatz ist, da sie einen p-Wert von weniger als 0,001 hat.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Abh\u00e4ngig vom Kontext des Problems k\u00f6nnen Sie sich entscheiden, diese Beobachtung aus dem Datensatz zu entfernen, da es sich um einen Ausrei\u00dfer handelt und die Analyseergebnisse beeintr\u00e4chtigen k\u00f6nnte.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\"><b>Verwandte Themen:<\/b><\/span> <a href=\"https:\/\/statorials.org\/de\/multivariater-normalitatstest-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">So f\u00fchren Sie multivariate Normalit\u00e4tstests in R durch<\/a><\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Der Mahalanobis-Abstand ist der Abstand zwischen zwei Punkten in einem multivariaten Raum. Es wird h\u00e4ufig verwendet, um Ausrei\u00dfer in statistischen Analysen mit mehreren Variablen zu erkennen. In diesem Tutorial wird erkl\u00e4rt, wie man den Mahalanobis-Abstand in R berechnet. Beispiel: Mahalanobis-Distanz in R Verwenden Sie die folgenden Schritte, um die Mahalanobis-Distanz f\u00fcr jede Beobachtung in einem [&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 berechnen Sie die Mahalanobis-Distanz in R - Statorials<\/title>\n<meta name=\"description\" content=\"Eine einfache Erkl\u00e4rung zur Berechnung des Mahalanobis-Abstands in R anhand eines 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\/mahalanobis-abstand-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So berechnen Sie die Mahalanobis-Distanz in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"Eine einfache Erkl\u00e4rung zur Berechnung des Mahalanobis-Abstands in R anhand eines Beispiels.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T07:59:26+00:00\" \/>\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\/mahalanobis-abstand-r\/\",\"url\":\"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/\",\"name\":\"So berechnen Sie die Mahalanobis-Distanz in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-28T07:59:26+00:00\",\"dateModified\":\"2023-07-28T07:59:26+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"Eine einfache Erkl\u00e4rung zur Berechnung des Mahalanobis-Abstands in R anhand eines Beispiels.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So berechnen sie den mahalanobis-abstand in r\"}]},{\"@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 berechnen Sie die Mahalanobis-Distanz in R - Statorials","description":"Eine einfache Erkl\u00e4rung zur Berechnung des Mahalanobis-Abstands in R anhand eines 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\/mahalanobis-abstand-r\/","og_locale":"de_DE","og_type":"article","og_title":"So berechnen Sie die Mahalanobis-Distanz in R - Statorials","og_description":"Eine einfache Erkl\u00e4rung zur Berechnung des Mahalanobis-Abstands in R anhand eines Beispiels.","og_url":"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/","og_site_name":"Statorials","article_published_time":"2023-07-28T07:59:26+00:00","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\/mahalanobis-abstand-r\/","url":"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/","name":"So berechnen Sie die Mahalanobis-Distanz in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-28T07:59:26+00:00","dateModified":"2023-07-28T07:59:26+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"Eine einfache Erkl\u00e4rung zur Berechnung des Mahalanobis-Abstands in R anhand eines Beispiels.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/mahalanobis-abstand-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So berechnen sie den mahalanobis-abstand in r"}]},{"@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\/915"}],"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=915"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/915\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}