{"id":4279,"date":"2023-07-12T08:16:16","date_gmt":"2023-07-12T08:16:16","guid":{"rendered":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/"},"modified":"2023-07-12T08:16:16","modified_gmt":"2023-07-12T08:16:16","slug":"extraheer-de-coefficienten-van-glm-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/","title":{"rendered":"Hoe regressieco\u00ebffici\u00ebnten uit glm() in r te extraheren"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende methoden gebruiken om regressieco\u00ebffici\u00ebnten uit de <strong>glm()<\/strong> -functie in R te extraheren:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: extraheer alle regressieco\u00ebffici\u00ebnten<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>model$coefficients\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 2: Extraheer de regressieco\u00ebffici\u00ebnt voor een specifieke variabele<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>model$coefficients[' <span style=\"color: #ff0000;\">my_variable<\/span> ']<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 3: Extraheer alle regressieco\u00ebffici\u00ebnten met standaardfout, Z-waarde en P-waarde<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>summary(model)$coefficients<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze methoden in de praktijk kunt gebruiken.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Voorbeeld: extraheer regressieco\u00ebffici\u00ebnten uit glm() in R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we een <a href=\"https:\/\/statorials.org\/nl\/logistische-regressie-1\/\" target=\"_blank\" rel=\"noopener\">logistisch regressiemodel<\/a> passen met behulp van de <strong>standaarddataset<\/strong> uit het <strong>ISLR-<\/strong> pakket:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#load dataset\n<\/span>data &lt;- ISLR::Default\n\n<span style=\"color: #008080;\">#view first six rows of data\n<\/span>head(data)\n\n  default student balance income\n1 No No 729.5265 44361.625\n2 No Yes 817.1804 12106.135\n3 No No 1073.5492 31767.139\n4 No No 529.2506 35704.494\n5 No No 785.6559 38463.496\n6 No Yes 919.5885 7491.559\n\n<span style=\"color: #008080;\">#fit logistic regression model\n<\/span>model &lt;- glm(default~student+balance+income, family=' <span style=\"color: #ff0000;\">binomial<\/span> ', data=data)\n\n<span style=\"color: #008080;\">#view summary of logistic regression model\n<\/span>summary(model)\n\nCall:\nglm(formula = default ~ student + balance + income, family = \"binomial\", \n    data = data)\n\nDeviance Residuals: \n    Min 1Q Median 3Q Max  \n-2.4691 -0.1418 -0.0557 -0.0203 3.7383  \n\nCoefficients:\n              Estimate Std. Error z value Pr(&gt;|z|)    \n(Intercept) -1.087e+01 4.923e-01 -22.080 &lt; 2e-16 ***\nstudentYes -6.468e-01 2.363e-01 -2.738 0.00619 ** \nbalance 5.737e-03 2.319e-04 24.738 &lt; 2e-16 ***\nincome 3.033e-06 8.203e-06 0.370 0.71152    \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\n(Dispersion parameter for binomial family taken to be 1)\n\n    Null deviance: 2920.6 on 9999 degrees of freedom\nResidual deviance: 1571.5 on 9996 degrees of freedom\nAIC: 1579.5\n\nNumber of Fisher Scoring iterations: 8<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen <strong>model$coefficients<\/strong> typen om alle regressieco\u00ebffici\u00ebnten uit het model te extraheren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract all regression coefficients\n<\/span>model$coefficients\n\n  (Intercept) studentYes balance income \n-1.086905e+01 -6.467758e-01 5.736505e-03 3.033450e-06\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">We kunnen ook <strong>model$coefficients[&#8218;balance&#8216;]<\/strong> typen om de regressieco\u00ebffici\u00ebnt alleen voor de <strong>balance-<\/strong> variabele te extraheren:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#extract coefficient for 'balance'\n<\/span>model$coefficients[' <span style=\"color: #ff0000;\">balance<\/span> ']\n\n<\/span><\/span>balance \n0.005736505\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Om de regressieco\u00ebffici\u00ebnten samen met hun standaardfouten, z-waarden en <a href=\"https:\/\/statorials.org\/nl\/p-waarden-statistische-significantie\/\" target=\"_blank\" rel=\"noopener\">p-waarden<\/a> weer te geven, kunnen we <strong>de summary(model)$-co\u00ebffici\u00ebnten<\/strong> als volgt gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view regression coefficients with standard errors, z values and p-values\n<\/span>summary(model)$coefficients\n\n                 Estimate Std. Error z value Pr(&gt;|z|)\n(Intercept) -1.086905e+01 4.922555e-01 -22.080088 4.911280e-108\nstudentYes -6.467758e-01 2.362525e-01 -2.737646 6.188063e-03\nbalance 5.736505e-03 2.318945e-04 24.737563 4.219578e-135\nincome 3.033450e-06 8.202615e-06 0.369815 7.115203e-01<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We hebben ook toegang tot specifieke waarden in deze uitvoer.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen bijvoorbeeld de volgende code gebruiken om toegang te krijgen tot de p-waarde van de <b>balance-<\/b> variabele:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view p-value for balance variable\n<\/span>summary(model)$coefficients[' <span style=\"color: #ff0000;\">balance<\/span> ', ' <span style=\"color: #ff0000;\">Pr(&gt;|z|)<\/span> ']\n\n[1] 4.219578e-135\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Of we kunnen de volgende code gebruiken om toegang te krijgen tot de p-waarde voor elk van de regressieco\u00ebffici\u00ebnten:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view p-value for all variables\n<\/span>summary(model)$coefficients[, ' <span style=\"color: #ff0000;\">Pr(&gt;|z|)<\/span> ']\n\n  (Intercept) studentYes balance income \n4.911280e-108 6.188063e-03 4.219578e-135 7.115203e-01 \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Voor elke regressieco\u00ebffici\u00ebnt in het model worden P-waarden weergegeven.<\/span><\/p>\n<p> <span style=\"color: #000000;\">U kunt een vergelijkbare syntaxis gebruiken om toegang te krijgen tot elke waarde in de uitvoer.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende taken in R kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/eenvoudige-lineaire-regressie-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe eenvoudige lineaire regressie uit te voeren in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/meervoudige-lineaire-regressie-r\/\" target=\"_blank\" rel=\"noopener\">Hoe meervoudige lineaire regressie uit te voeren in R<\/a><br \/> Hoe logistische regressie uit te voeren in R<br \/> <a href=\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/\" target=\"_blank\" rel=\"noopener\">Hoe kwadratische regressie uit te voeren in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende methoden gebruiken om regressieco\u00ebffici\u00ebnten uit de glm() -functie in R te extraheren: Methode 1: extraheer alle regressieco\u00ebffici\u00ebnten model$coefficients Methode 2: Extraheer de regressieco\u00ebffici\u00ebnt voor een specifieke variabele model$coefficients[&#8218; my_variable &#8218;] Methode 3: Extraheer alle regressieco\u00ebffici\u00ebnten met standaardfout, Z-waarde en P-waarde summary(model)$coefficients Het volgende voorbeeld laat zien hoe u deze methoden 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":[],"class_list":["post-4279","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 regressieco\u00ebffici\u00ebnten uit glm() te extraheren in R - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u co\u00ebffici\u00ebnten kunt extraheren uit de uitvoer van de glm()-functie in R.\" \/>\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\/extraheer-de-coefficienten-van-glm-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe regressieco\u00ebffici\u00ebnten uit glm() te extraheren in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u co\u00ebffici\u00ebnten kunt extraheren uit de uitvoer van de glm()-functie in R.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-12T08:16:16+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=\"3\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/\",\"name\":\"Hoe regressieco\u00ebffici\u00ebnten uit glm() te extraheren in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-12T08:16:16+00:00\",\"dateModified\":\"2023-07-12T08:16:16+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u co\u00ebffici\u00ebnten kunt extraheren uit de uitvoer van de glm()-functie in R.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe regressieco\u00ebffici\u00ebnten uit glm() in r te extraheren\"}]},{\"@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 regressieco\u00ebffici\u00ebnten uit glm() te extraheren in R - Statorials","description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u co\u00ebffici\u00ebnten kunt extraheren uit de uitvoer van de glm()-functie in R.","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\/extraheer-de-coefficienten-van-glm-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe regressieco\u00ebffici\u00ebnten uit glm() te extraheren in R - Statorials","og_description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u co\u00ebffici\u00ebnten kunt extraheren uit de uitvoer van de glm()-functie in R.","og_url":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-12T08:16:16+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"3\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/","url":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/","name":"Hoe regressieco\u00ebffici\u00ebnten uit glm() te extraheren in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-12T08:16:16+00:00","dateModified":"2023-07-12T08:16:16+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u co\u00ebffici\u00ebnten kunt extraheren uit de uitvoer van de glm()-functie in R.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/extraheer-de-coefficienten-van-glm-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe regressieco\u00ebffici\u00ebnten uit glm() in r te extraheren"}]},{"@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\/4279","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=4279"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4279\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=4279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=4279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=4279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}