{"id":4173,"date":"2023-07-13T02:55:29","date_gmt":"2023-07-13T02:55:29","guid":{"rendered":"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/"},"modified":"2023-07-13T02:55:29","modified_gmt":"2023-07-13T02:55:29","slug":"r-extraheer-de-p-waarde-uit-lm","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/","title":{"rendered":"Hoe p-waarden te extraheren uit de lm()-functie in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende methoden gebruiken om p-waarden uit de <a href=\"https:\/\/statorials.org\/nl\/lm-functie-in-r\/\" target=\"_blank\" rel=\"noopener\">functie lm()<\/a> in R te extraheren:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: Haal de totale P-waarde uit het regressiemodel<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define function to extract overall p-value of model<\/span>\noverall_p &lt;- <span style=\"color: #008000;\">function<\/span> (my_model) {\n    f &lt;- summary(my_model)$fstatistic\n    p &lt;- pf(f[1],f[2],f[3],lower. <span style=\"color: #3366ff;\">tail<\/span> =F)\n    attributes(p) &lt;- NULL\n    <span style=\"color: #008000;\">return<\/span> (p)\n}\n\n<span style=\"color: #008080;\">#extract overall p-value of model<\/span>\noverall_p(model)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 2: Extraheer individuele P-waarden voor regressieco\u00ebffici\u00ebnten<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>summary(model)$coefficients[,4]<\/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 P-waarden uit lm() in R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende <a href=\"https:\/\/statorials.org\/nl\/meerdere-lineaire-regressie\/\" target=\"_blank\" rel=\"noopener\">meervoudige lineaire regressiemodel<\/a> in R passen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (rating=c(67, 75, 79, 85, 90, 96, 97),\n                 points=c(8, 12, 16, 15, 22, 28, 24),\n                 assists=c(4, 6, 6, 5, 3, 8, 7),\n                 rebounds=c(1, 4, 3, 3, 2, 6, 7))\n\n<span style=\"color: #008080;\">#fit multiple linear regression model\n<\/span>model &lt;- lm(rating ~ points + assists + rebounds, data=df)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de functie <strong>summary()<\/strong> gebruiken om de volledige samenvatting van het regressiemodel weer te geven:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view model summary\n<\/span>summary(model)\n\nCall:\nlm(formula = rating ~ points + assists + rebounds, data = df)\n\nResiduals:\n      1 2 3 4 5 6 7 \n-1.5902 -1.7181 0.2413 4.8597 -1.0201 -0.6082 -0.1644 \n\nCoefficients:\n            Estimate Std. Error t value Pr(&gt;|t|)   \n(Intercept) 66.4355 6.6932 9.926 0.00218 **\npoints 1.2152 0.2788 4.359 0.02232 * \nassists -2.5968 1.6263 -1.597 0.20860   \nrebounds 2.8202 1.6118 1.750 0.17847   \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 3.193 on 3 degrees of freedom\nMultiple R-squared: 0.9589, Adjusted R-squared: 0.9179 \nF-statistic: 23.35 on 3 and 3 DF, p-value: 0.01396\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Helemaal onderaan het resultaat kunnen we zien dat de totale p-waarde van het regressiemodel <strong>0,01396<\/strong> is.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Als we alleen deze p-waarde uit het model willen extraheren, kunnen we hiervoor een aangepaste functie defini\u00ebren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define function to extract overall p-value of model<\/span>\noverall_p &lt;- <span style=\"color: #008000;\">function<\/span> (my_model) {\n    f &lt;- summary(my_model)$fstatistic\n    p &lt;- pf(f[1],f[2],f[3],lower. <span style=\"color: #3366ff;\">tail<\/span> =F)\n    attributes(p) &lt;- NULL\n    <span style=\"color: #008000;\">return<\/span> (p)\n}\n\n<span style=\"color: #008080;\">#extract overall p-value of model<\/span>\noverall_p(model)\n\n[1] 0.01395572\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat de functie dezelfde p-waarde retourneert als de bovenstaande modeluitvoer.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Om p-waarden voor individuele regressieco\u00ebffici\u00ebnten uit het model te extraheren, kunnen we de volgende syntaxis gebruiken:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract p-values for individual regression coefficients in model\n<span style=\"color: #000000;\">summary(model)$coefficients[,4] \n\n(Intercept) points assists rebounds \n0.002175313 0.022315418 0.208600183 0.178471275<\/span><\/span>\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat de hier getoonde p-waarden overeenkomen met die in de <strong>Pr(&gt; |t|)<\/strong> kolom in de regressie-uitvoer hierboven.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Gerelateerd:<\/strong> <a href=\"https:\/\/statorials.org\/nl\/extraheer-r-kwadraat-van-lm-naar-r\/\" target=\"_blank\" rel=\"noopener\">Hoe de R-kwadraat uit de functie lm() in R te extraheren<\/a><\/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 \/> <a href=\"https:\/\/statorials.org\/nl\/restspoor-r\/\" target=\"_blank\" rel=\"noopener\">Hoe maak je een restplot in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende methoden gebruiken om p-waarden uit de functie lm() in R te extraheren: Methode 1: Haal de totale P-waarde uit het regressiemodel #define function to extract overall p-value of model overall_p &lt;- function (my_model) { f &lt;- summary(my_model)$fstatistic p &lt;- pf(f[1],f[2],f[3],lower. tail =F) attributes(p) &lt;- NULL return (p) } #extract overall p-value [&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-4173","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 P-waarden te extraheren uit de lm()-functie in R - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van de functie lm() 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\/r-extraheer-de-p-waarde-uit-lm\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe P-waarden te extraheren uit de lm()-functie in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van de functie lm() in R.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-13T02:55:29+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\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/\",\"url\":\"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/\",\"name\":\"Hoe P-waarden te extraheren uit de lm()-functie in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-13T02:55:29+00:00\",\"dateModified\":\"2023-07-13T02:55:29+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van de functie lm() in R.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe p-waarden te extraheren uit de lm()-functie in r\"}]},{\"@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 P-waarden te extraheren uit de lm()-functie in R - Statorials","description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van de functie lm() 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\/r-extraheer-de-p-waarde-uit-lm\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe P-waarden te extraheren uit de lm()-functie in R - Statorials","og_description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van de functie lm() in R.","og_url":"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/","og_site_name":"Statorials","article_published_time":"2023-07-13T02:55:29+00:00","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\/r-extraheer-de-p-waarde-uit-lm\/","url":"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/","name":"Hoe P-waarden te extraheren uit de lm()-functie in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-13T02:55:29+00:00","dateModified":"2023-07-13T02:55:29+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van de functie lm() in R.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/r-extraheer-de-p-waarde-uit-lm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe p-waarden te extraheren uit de lm()-functie in r"}]},{"@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\/4173","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=4173"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4173\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=4173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=4173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=4173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}