{"id":3442,"date":"2023-07-17T11:29:47","date_gmt":"2023-07-17T11:29:47","guid":{"rendered":"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/"},"modified":"2023-07-17T11:29:47","modified_gmt":"2023-07-17T11:29:47","slug":"statsmodels-lineaire-regressie-p-waarde","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/","title":{"rendered":"Hoe p-waarden uit lineaire regressie in statistische modellen kunnen worden gehaald"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende methoden gebruiken om p-waarden te extraheren voor co\u00ebffici\u00ebnten in een lineaire regressiemodelpassing met behulp van de <a href=\"https:\/\/www.statsmodels.org\/stable\/index.html\" target=\"_blank\" rel=\"noopener\">statsmodels-<\/a> module in Python:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract p-values for all predictor variables\n<\/span><span style=\"color: #008000;\">for<\/span> x <span style=\"color: #008000;\">in<\/span> range(0, 3):\n    <span style=\"color: #008000;\">print<\/span> ( <span style=\"color: #3366ff;\">model.pvalues<\/span> [x])\n\n<span style=\"color: #008080;\">#extract p-value for specific predictor variable name\n<\/span>model. <span style=\"color: #3366ff;\">pvalues<\/span> . <span style=\"color: #3366ff;\">loc<\/span> [' <span style=\"color: #ff0000;\">predictor1<\/span> ']\n\n<span style=\"color: #008080;\">#extract p-value for specific predictor variable position<\/span>\nmodel. <span style=\"color: #3366ff;\">pvalues<\/span> [0]\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De volgende voorbeelden laten zien hoe u elke methode in de praktijk kunt gebruiken.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Voorbeeld: Extraheer P-waarden uit lineaire regressie in statistische modellen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende panda&#8217;s DataFrame hebben dat informatie bevat over de gestudeerde uren, de afgelegde voorbereidende examens en het eindcijfer dat studenten in een bepaalde klas hebben ontvangen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> pandas <span style=\"color: #107d3f;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#createDataFrame\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">hours<\/span> ': [1, 2, 2, 4, 2, 1, 5, 4, 2, 4, 4, 3, 6],\n                   ' <span style=\"color: #ff0000;\">exams<\/span> ': [1, 3, 3, 5, 2, 2, 1, 1, 0, 3, 4, 3, 2],\n                   ' <span style=\"color: #ff0000;\">score<\/span> ': [76, 78, 85, 88, 72, 69, 94, 94, 88, 92, 90, 75, 96]})\n\n<span style=\"color: #008080;\">#view head of DataFrame\n<\/span>df. <span style=\"color: #3366ff;\">head<\/span> ()\n\n\thours exam score\n0 1 1 76\n1 2 3 78\n2 2 3 85\n3 4 5 88\n4 2 2 72<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de <strong>OLS()<\/strong> -functie van de statsmodels-module gebruiken om een <a href=\"https:\/\/statorials.org\/nl\/meerdere-lineaire-regressie\/\" target=\"_blank\" rel=\"noopener\">meervoudig lineair regressiemodel<\/a> te passen, met behulp van &#8222;uren&#8220; en &#8222;examens&#8220; als voorspellende variabelen en &#8222;score&#8220; als<a href=\"https:\/\/statorials.org\/nl\/variabelen-verklarende-reacties\/\" target=\"_blank\" rel=\"noopener\">de responsvariabele<\/a> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> statsmodels. <span style=\"color: #3366ff;\">api<\/span> <span style=\"color: #107d3f;\">as<\/span> sm\n\n<span style=\"color: #008080;\">#define predictor and response variables\n<\/span>y = df['score']\nx = df[['hours', 'exams']]\n\n<span style=\"color: #008080;\">#add constant to predictor variables\n<\/span>x = sm. <span style=\"color: #3366ff;\">add_constant<\/span> (x)\n\n<span style=\"color: #008080;\">#fit linear regression model\n<\/span>model = sm. <span style=\"color: #3366ff;\">OLS<\/span> (y,x). <span style=\"color: #3366ff;\">fit<\/span> ()\n\n<span style=\"color: #008080;\">#view model summary\n<\/span><span style=\"color: #008000;\">print<\/span> ( <span style=\"color: #3366ff;\">model.summary<\/span> ())\n\n                            OLS Regression Results                            \n==================================================== ============================\nDept. Variable: R-squared score: 0.718\nModel: OLS Adj. R-squared: 0.661\nMethod: Least Squares F-statistic: 12.70\nDate: Fri, 05 Aug 2022 Prob (F-statistic): 0.00180\nTime: 09:24:38 Log-Likelihood: -38.618\nNo. Observations: 13 AIC: 83.24\nDf Residuals: 10 BIC: 84.93\nDf Model: 2                                         \nCovariance Type: non-robust                                         \n==================================================== ============================\n                 coef std err t P&gt;|t| [0.025 0.975]\n-------------------------------------------------- ----------------------------\nconst 71.4048 4.001 17.847 0.000 62.490 80.319\nhours 5.1275 1.018 5.038 0.001 2.860 7.395\nexams -1.2121 1.147 -1.057 0.315 -3.768 1.344\n==================================================== ============================\nOmnibus: 1,103 Durbin-Watson: 1,248\nProb(Omnibus): 0.576 Jarque-Bera (JB): 0.803\nSkew: -0.289 Prob(JB): 0.669\nKurtosis: 1.928 Cond. No. 11.7\n==================================================== ============================\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Standaard geeft de functie <strong>summary()<\/strong> de p-waarden van elke voorspellende variabele weer met maximaal drie decimalen:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">P-waarde voor onderschepping: <strong>0,000<\/strong><\/span><\/li>\n<li> <span style=\"color: #000000;\">P-waarde voor uren: <strong>0,001<\/strong><\/span><\/li>\n<li> <span style=\"color: #000000;\">P-waarde voor examens: <strong>0,315<\/strong><\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">We kunnen echter de volledige p-waarden voor elke voorspellende variabele uit het model extraheren met behulp van de volgende syntaxis:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract p-values for all predictor variables\n<\/span><span style=\"color: #008000;\">for<\/span> x <span style=\"color: #008000;\">in<\/span> range(0, 3):\n    <span style=\"color: #008000;\">print<\/span> ( <span style=\"color: #3366ff;\">model.pvalues<\/span> [x])\n\n6.514115622692573e-09\n0.0005077783375870773\n0.3154807854805659\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Hierdoor kunnen we p-waarden met meer decimalen zien:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">P-waarde voor onderschepping: <strong>0,00000000651411562269257<\/strong><\/span><\/li>\n<li> <span style=\"color: #000000;\">P-waarde voor uren: <strong>0,0005077783375870773<\/strong><\/span><\/li>\n<li> <span style=\"color: #000000;\">P-waarde voor examens: <strong>0,3154807854805659<\/strong><\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\"><strong>Opmerking<\/strong> : we hebben <strong>3<\/strong> gebruikt in onze <strong>range()<\/strong> -functie omdat er drie totale co\u00ebffici\u00ebnten waren in ons regressiemodel.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen ook de volgende syntaxis gebruiken om specifiek de p-waarde voor de variabele &#8222;uren&#8220; te extraheren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract p-value for 'hours' only\n<\/span>model. <span style=\"color: #3366ff;\">pvalues<\/span> . <span style=\"color: #3366ff;\">loc<\/span> [' <span style=\"color: #ff0000;\">hours<\/span> ']\n\n0.0005077783375870773\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Of we kunnen de volgende syntaxis gebruiken om de p-waarde van de co\u00ebffici\u00ebnt van een variabele in een specifieke positie van het regressiemodel te extraheren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract p-value for coefficient in index position 0\n<\/span>model. <span style=\"color: #3366ff;\">pvalues<\/span> [0]\n\n6.514115622692573e-09<\/strong><\/pre>\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 Python kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/logistische-regressiepython\/\" target=\"_blank\" rel=\"noopener\">Hoe logistieke regressie uit te voeren in Python<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/aic-in-python\/\" target=\"_blank\" rel=\"noopener\">Hoe AIC van regressiemodellen in Python te berekenen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/r-vierkant-in-python-wordt-aangepast\/\" target=\"_blank\" rel=\"noopener\">Hoe aangepaste R-kwadraat in Python te berekenen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende methoden gebruiken om p-waarden te extraheren voor co\u00ebffici\u00ebnten in een lineaire regressiemodelpassing met behulp van de statsmodels- module in Python: #extract p-values for all predictor variables for x in range(0, 3): print ( model.pvalues [x]) #extract p-value for specific predictor variable name model. pvalues . loc [&#8218; predictor1 &#8218;] #extract 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-3442","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 uit lineaire regressie in statistische modellen te extraheren - 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 een lineair regressiemodel in Statistics Models in Python.\" \/>\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\/statsmodels-lineaire-regressie-p-waarde\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe P-waarden uit lineaire regressie in statistische modellen te extraheren - 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 een lineair regressiemodel in Statistics Models in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-17T11:29:47+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\/statsmodels-lineaire-regressie-p-waarde\/\",\"url\":\"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/\",\"name\":\"Hoe P-waarden uit lineaire regressie in statistische modellen te extraheren - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-17T11:29:47+00:00\",\"dateModified\":\"2023-07-17T11:29:47+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 een lineair regressiemodel in Statistics Models in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe p-waarden uit lineaire regressie in statistische modellen kunnen worden gehaald\"}]},{\"@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 uit lineaire regressie in statistische modellen te extraheren - Statorials","description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van een lineair regressiemodel in Statistics Models in Python.","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\/statsmodels-lineaire-regressie-p-waarde\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe P-waarden uit lineaire regressie in statistische modellen te extraheren - Statorials","og_description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je p-waarden kunt extraheren uit de uitvoer van een lineair regressiemodel in Statistics Models in Python.","og_url":"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/","og_site_name":"Statorials","article_published_time":"2023-07-17T11:29:47+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\/statsmodels-lineaire-regressie-p-waarde\/","url":"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/","name":"Hoe P-waarden uit lineaire regressie in statistische modellen te extraheren - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-17T11:29:47+00:00","dateModified":"2023-07-17T11:29:47+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 een lineair regressiemodel in Statistics Models in Python.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/statsmodels-lineaire-regressie-p-waarde\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe p-waarden uit lineaire regressie in statistische modellen kunnen worden gehaald"}]},{"@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\/3442","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=3442"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3442\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}