{"id":1311,"date":"2023-07-26T22:17:32","date_gmt":"2023-07-26T22:17:32","guid":{"rendered":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/"},"modified":"2023-07-26T22:17:32","modified_gmt":"2023-07-26T22:17:32","slug":"residuen-gestandaardiseerd-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/","title":{"rendered":"Hoe gestandaardiseerde residuen in r te berekenen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Een <strong>residu<\/strong> is het verschil tussen een waargenomen waarde en een voorspelde waarde in een<a href=\"https:\/\/statorials.org\/nl\/lineaire-regressie-1\/\" target=\"_blank\" rel=\"noopener noreferrer\">regressiemodel<\/a> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het wordt als volgt berekend:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Residueel = Waargenomen waarde \u2013 Voorspelde waarde<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Als we de waargenomen waarden uitzetten en de aangepaste regressielijn over elkaar leggen, zijn de residuen voor elke <a href=\"https:\/\/statorials.org\/nl\/observatie-in-de-statistiek\/\" target=\"_blank\" rel=\"noopener\">waarneming<\/a> de verticale afstand tussen de waarneming en de regressielijn:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-12422 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/residus1-1.png\" alt=\"Voorbeeld van residu in statistieken\" width=\"487\" height=\"382\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">E\u00e9n type residu dat we vaak gebruiken om uitschieters in een regressiemodel te identificeren, wordt <strong>een gestandaardiseerd residu<\/strong> genoemd.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het wordt als volgt berekend:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>r <sub>ik<\/sub> = e <sub>ik<\/sub> \/ s(e <sub>ik<\/sub> )<\/strong> = <strong>e <sub>ik<\/sub> \/ RSE\u221a <span style=\"border-top: 1px solid black;\">1-h <sub>ii<\/sub><\/span><\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Goud:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>e <sub>i<\/sub> :<\/strong> het i- <sup>de<\/sup> residu<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>RSE:<\/strong> de resterende standaardfout van het model<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>h <sub>ii<\/sub><\/strong> : De opkomst van de <sup>ide<\/sup> waarneming<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">In de praktijk beschouwen we vaak elk gestandaardiseerd residu waarvan de absolute waarde groter is dan 3 als een uitbijter.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Deze tutorial biedt een stapsgewijs voorbeeld van hoe u gestandaardiseerde residuen in R kunt berekenen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Stap 1: Voer de gegevens in<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Eerst maken we een kleine dataset om mee te werken in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data<\/span>\ndata &lt;- data.frame(x=c(8, 12, 12, 13, 14, 16, 17, 22, 24, 26, 29, 30),\n                   y=c(41, 42, 39, 37, 35, 39, 45, 46, 39, 49, 55, 57))\n\n<span style=\"color: #008080;\">#viewdata\n<\/span>data\n\n    xy\n1 8 41\n2 12 42\n3 12 39\n4 13 37\n5 14 35\n6 16 39\n7 17 45\n8 22 46\n9 24 39\n10 26 49\n11 29 55\n12 30 57<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Stap 2: Pas het regressiemodel aan<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Vervolgens zullen we de functie <strong>lm()<\/strong> gebruiken om een <a href=\"https:\/\/statorials.org\/nl\/eenvoudige-lineaire-regressie-in-r\/\" target=\"_blank\" rel=\"noopener\">eenvoudig lineair regressiemodel<\/a> te passen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#fit model\n<\/span>model &lt;- lm(y ~ x, data=data)\n\n<span style=\"color: #008080;\">#view model summary\n<span style=\"color: #000000;\">summary(model)<\/span> \n\n<span style=\"color: #000000;\">Call:\nlm(formula = y ~ x, data = data)\n\nResiduals:\n    Min 1Q Median 3Q Max \n-8.7578 -2.5161 0.0292 3.3457 5.3268 \n\nCoefficients:\n            Estimate Std. Error t value Pr(&gt;|t|)    \n(Intercept) 29.6309 3.6189 8.188 9.6e-06 ***\nx 0.7553 0.1821 4.148 0.00199 ** \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 4.442 on 10 degrees of freedom\nMultiple R-squared: 0.6324, Adjusted R-squared: 0.5956 \nF-statistic: 17.2 on 1 and 10 DF, p-value: 0.001988<\/span><\/span><\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Stap 3: Bereken gestandaardiseerde residuen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Vervolgens zullen we de ingebouwde functie <strong>rstandard()<\/strong> gebruiken om de gestandaardiseerde residuen van het model te berekenen:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate the standardized residuals\n<\/span>standard_res &lt;- rstandard(model)\n\n<span style=\"color: #008080;\">#view the standardized residuals<\/span>\nstandard_res\n\n          1 2 3 4 5 6 \n 1.40517322 0.81017562 0.07491009 -0.59323342 -1.24820530 -0.64248883 \n          7 8 9 10 11 12 \n 0.59610905 -0.05876884 -2.11711982 -0.06655600 0.91057211 1.26973888\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de gestandaardiseerde residuen aan het originele dataframe toevoegen als we dat willen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#column bind standardized residuals back to original data frame\n<\/span>final_data &lt;- cbind(data, standard_res)\n\n<span style=\"color: #008080;\">#view data frame<\/span>\n    xy standard_res\n1 8 41 1.40517322\n2 12 42 0.81017562\n3 12 39 0.07491009\n4 13 37 -0.59323342\n5 14 35 -1.24820530\n6 16 39 -0.64248883\n7 17 45 0.59610905\n8 22 46 -0.05876884\n9 24 39 -2.11711982\n10 26 49 -0.06655600\n11 29 55 0.91057211\n12 30 57 1.26973888\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen vervolgens elke waarneming sorteren van groot naar klein op basis van het gestandaardiseerde residu om een idee te krijgen van welke waarnemingen het dichtst bij de uitschieters liggen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#sort standardized residuals descending\n<span style=\"color: #000000;\">final_data[ <span style=\"color: #3366ff;\">order<\/span> (-standard_res),]\n\n    xy standard_res\n1 8 41 1.40517322\n12 30 57 1.26973888\n11 29 55 0.91057211\n2 12 42 0.81017562\n7 17 45 0.59610905\n3 12 39 0.07491009\n8 22 46 -0.05876884\n10 26 49 -0.06655600\n4 13 37 -0.59323342\n6 16 39 -0.64248883\n5 14 35 -1.24820530\n9 24 39 -2.11711982<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit de resultaten kunnen we opmaken dat geen van de gestandaardiseerde residuen een absolute waarde van 3 overschrijdt. Geen van de waarnemingen lijkt dus uitschieters te zijn.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Stap 4: Visualiseer de gestandaardiseerde residuen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Ten slotte kunnen we een spreidingsdiagram maken om de waarden van de voorspellende variabele te visualiseren ten opzichte van de gestandaardiseerde residuen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#plot predictor variable vs. standardized residuals\n<\/span>plot(final_data$x, standard_res, ylab=' <span style=\"color: #008000;\">Standardized Residuals<\/span> ', xlab=' <span style=\"color: #008000;\">x<\/span> ') \n\n<span style=\"color: #008080;\">#add horizontal line at 0\n<\/span>abline(0, 0)<\/span><\/span><\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/nl\/residu\/\" target=\"_blank\" rel=\"noopener\">Wat zijn residuen?<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/gestandaardiseerde-residuen\/\">Wat zijn gestandaardiseerde residuen?<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/meerdere-lineaire-regressie\/\" target=\"_blank\" rel=\"noopener\">Inleiding tot meervoudige lineaire regressie<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een residu is het verschil tussen een waargenomen waarde en een voorspelde waarde in eenregressiemodel . Het wordt als volgt berekend: Residueel = Waargenomen waarde \u2013 Voorspelde waarde Als we de waargenomen waarden uitzetten en de aangepaste regressielijn over elkaar leggen, zijn de residuen voor elke waarneming de verticale afstand tussen de waarneming en de [&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":[],"class_list":["post-1311","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe gestandaardiseerde residuen in R te berekenen<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u gestandaardiseerde residuen in R kunt berekenen, inclusief een stapsgewijs voorbeeld.\" \/>\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\/nl\/residuen-gestandaardiseerd-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe gestandaardiseerde residuen in R te berekenen\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u gestandaardiseerde residuen in R kunt berekenen, inclusief een stapsgewijs voorbeeld.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-26T22:17:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/residus1-1.png\" \/>\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\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/\",\"name\":\"Hoe gestandaardiseerde residuen in R te berekenen\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-26T22:17:32+00:00\",\"dateModified\":\"2023-07-26T22:17:32+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u gestandaardiseerde residuen in R kunt berekenen, inclusief een stapsgewijs voorbeeld.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe gestandaardiseerde residuen in r te berekenen\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe gestandaardiseerde residuen in R te berekenen","description":"In deze tutorial wordt uitgelegd hoe u gestandaardiseerde residuen in R kunt berekenen, inclusief een stapsgewijs voorbeeld.","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\/nl\/residuen-gestandaardiseerd-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe gestandaardiseerde residuen in R te berekenen","og_description":"In deze tutorial wordt uitgelegd hoe u gestandaardiseerde residuen in R kunt berekenen, inclusief een stapsgewijs voorbeeld.","og_url":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-26T22:17:32+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/residus1-1.png"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/","url":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/","name":"Hoe gestandaardiseerde residuen in R te berekenen","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-26T22:17:32+00:00","dateModified":"2023-07-26T22:17:32+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u gestandaardiseerde residuen in R kunt berekenen, inclusief een stapsgewijs voorbeeld.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/residuen-gestandaardiseerd-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe gestandaardiseerde residuen in r te berekenen"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=1311"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1311\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}