{"id":827,"date":"2023-07-28T15:16:06","date_gmt":"2023-07-28T15:16:06","guid":{"rendered":"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/"},"modified":"2023-07-28T15:16:06","modified_gmt":"2023-07-28T15:16:06","slug":"gedeeltelijke-correlatiepython","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/","title":{"rendered":"Hoe gedeeltelijke correlatie in python te berekenen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">In de statistiek gebruiken we vaak de<\/span><a href=\"https:\/\/statorials.org\/nl\/pearson-correlatiecoefficient-1\/\" target=\"_blank\" rel=\"noopener\">Pearson-correlatieco\u00ebffici\u00ebnt<\/a> <span style=\"color: #000000;\">om de lineaire relatie tussen twee variabelen te meten. Soms willen we echter de relatie tussen twee variabelen begrijpen <strong>terwijl we een derde variabele controleren<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Stel dat we bijvoorbeeld het verband willen meten tussen het aantal studie-uren van een leerling en het eindexamencijfer, terwijl we controleren voor het huidige cijfer van de leerling in de klas. In dit geval kunnen we <strong>parti\u00eble correlatie<\/strong> gebruiken om de relatie tussen het aantal gestudeerde uren en het eindexamencijfer te meten.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial wordt uitgelegd hoe je een gedeeltelijke correlatie in Python berekent.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld: gedeeltelijke correlatie in Python<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Laten we zeggen dat we het volgende Pandas DataFrame hebben dat het huidige cijfer, het totaal aantal bestudeerde uren en het eindexamencijfer voor 10 studenten weergeeft:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> numpy <span style=\"color: #107d3f;\">as<\/span> np\n<span style=\"color: #107d3f;\">import<\/span> panda <span style=\"color: #107d3f;\">as<\/span> pd\n\ndata = {'currentGrade': [82, 88, 75, 74, 93, 97, 83, 90, 90, 80],\n        'hours': [4, 3, 6, 5, 4, 5, 8, 7, 4, 6],\n        'examScore': [88, 85, 76, 70, 92, 94, 89, 85, 90, 93],\n        }\n\ndf = pd.DataFrame(data, columns = ['currentGrade','hours', 'examScore'])\ndf\n\n   currentGrade hours examScore\n0 82 4 88\n1 88 3 85\n2 75 6 76\n3 74 5 70\n4 93 4 92\n5 97 5 94\n6 83 8 89\n7 90 7 85\n8 90 4 90\n9 80 6 93\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Om de gedeeltelijke correlatie tussen <strong>uren<\/strong> en <strong>examScore<\/strong> te berekenen terwijl <strong>currentGrade<\/strong> wordt beheerd, kunnen we de functie <strong>Partial_corr()<\/strong> uit het <a href=\"https:\/\/pingouin-stats.org\/index.html\" target=\"_blank\" rel=\"noopener\">Penguin-pakket<\/a> gebruiken, die de volgende syntaxis gebruikt:<\/span><\/p>\n<p style=\"text-align: center;\"> <strong><span style=\"color: #000000;\">gedeeltelijke_corr(gegevens, x, y, covar)<\/span><\/strong><\/p>\n<p> <span style=\"color: #000000;\">Goud:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>data:<\/strong> naam van het dataframe<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>x, y:<\/strong> kolomnamen in het dataframe<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>covar:<\/strong> de naam van de covariabelekolom in het dataframe (bijvoorbeeld de variabele die u beheert)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Hier ziet u hoe u deze functie in dit specifieke voorbeeld kunt gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#install and import penguin package<\/span> \npip <span style=\"color: #107d3f;\">install<\/span> penguin\n<span style=\"color: #107d3f;\">import<\/span> penguin <span style=\"color: #107d3f;\">as<\/span> pg\n\n<span style=\"color: #008080;\">#find partial correlation between hours and exam score while controlling for grade<\/span>\npg.partial_corr(data=df, x='hours', y='examScore', covar='currentGrade')\n\n\n         n r CI95% r2 adj_r2 p-val BF10 power\npearson 10 0.191 [-0.5, 0.73] 0.036 -0.238 0.598 0.438 0.082\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen zien dat de gedeeltelijke correlatie tussen het aantal gestudeerde uren en het eindexamencijfer <strong>0,191<\/strong> is, wat een kleine positieve correlatie is. Naarmate het aantal studie-uren toeneemt, stijgen ook de examencijfers, ervan uitgaande dat het huidige cijfer constant blijft.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Om de gedeeltelijke correlatie tussen meerdere variabelen tegelijk te berekenen, kunnen we de functie <strong>.pcorr()<\/strong> gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate all pairwise partial correlations, rounded to three decimal places<\/span>\ndf.pcorr().round(3)\n\n\t     currentGrade hours examScore\ncurrentGrade 1.000 -0.311 0.736\nhours -0.311 1.000 0.191\nexamScore 0.736 0.191 1.000\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De manier om het resultaat te interpreteren is als volgt:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">De gedeeltelijke correlatie tussen het huidige cijfer en het aantal gestudeerde uren is <strong>-0,311<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De deelcorrelatie tussen huidig cijfer en examencijfer <strong>0,736<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De gedeeltelijke correlatie tussen gestudeerde uren en examenscore <strong>0,191<\/strong> .<\/span><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In de statistiek gebruiken we vaak dePearson-correlatieco\u00ebffici\u00ebnt om de lineaire relatie tussen twee variabelen te meten. Soms willen we echter de relatie tussen twee variabelen begrijpen terwijl we een derde variabele controleren . Stel dat we bijvoorbeeld het verband willen meten tussen het aantal studie-uren van een leerling en het eindexamencijfer, terwijl we controleren voor [&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-827","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 een gedeeltelijke correlatie in Python te berekenen - Statorials<\/title>\n<meta name=\"description\" content=\"Een eenvoudige uitleg over het berekenen van gedeeltelijke correlatie 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\/gedeeltelijke-correlatiepython\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe een gedeeltelijke correlatie in Python te berekenen - Statorials\" \/>\n<meta property=\"og:description\" content=\"Een eenvoudige uitleg over het berekenen van gedeeltelijke correlatie in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T15:16:06+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\/gedeeltelijke-correlatiepython\/\",\"url\":\"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/\",\"name\":\"Hoe een gedeeltelijke correlatie in Python te berekenen - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-28T15:16:06+00:00\",\"dateModified\":\"2023-07-28T15:16:06+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"Een eenvoudige uitleg over het berekenen van gedeeltelijke correlatie in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe gedeeltelijke correlatie in python 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 een gedeeltelijke correlatie in Python te berekenen - Statorials","description":"Een eenvoudige uitleg over het berekenen van gedeeltelijke correlatie 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\/gedeeltelijke-correlatiepython\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe een gedeeltelijke correlatie in Python te berekenen - Statorials","og_description":"Een eenvoudige uitleg over het berekenen van gedeeltelijke correlatie in Python.","og_url":"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/","og_site_name":"Statorials","article_published_time":"2023-07-28T15:16:06+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\/gedeeltelijke-correlatiepython\/","url":"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/","name":"Hoe een gedeeltelijke correlatie in Python te berekenen - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-28T15:16:06+00:00","dateModified":"2023-07-28T15:16:06+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"Een eenvoudige uitleg over het berekenen van gedeeltelijke correlatie in Python.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatiepython\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe gedeeltelijke correlatie in python 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\/827","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=827"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}