{"id":783,"date":"2023-07-28T18:44:38","date_gmt":"2023-07-28T18:44:38","guid":{"rendered":"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/"},"modified":"2023-07-28T18:44:38","modified_gmt":"2023-07-28T18:44:38","slug":"kwadratische-regressie-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/","title":{"rendered":"Hoe kwadratische regressie uit te voeren in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Wanneer twee variabelen een lineair verband hebben, kunnen we vaak <a href=\"https:\/\/statorials.org\/nl\/eenvoudige-lineaire-regressie-in-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">eenvoudige lineaire regressie<\/a> gebruiken om hun verband te kwantificeren.<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-5772 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadregstata1.png\" sizes=\"auto, \" srcset=\"\" alt=\"Voorbeeld van lineaire relatie\" width=\"442\" height=\"318\"><\/p>\n<p> <span style=\"color: #000000;\">Wanneer twee variabelen echter een kwadratische relatie hebben, kunnen we <strong>kwadratische regressie<\/strong> gebruiken om hun relatie te kwantificeren.<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-5773 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadregstata2.png\" sizes=\"auto, \" srcset=\"\" alt=\"Voorbeeld van een kwadratische relatie\" width=\"441\" height=\"319\"><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial wordt uitgelegd hoe u kwadratische regressie uitvoert in R.<\/span><\/p>\n<h3> <strong>Voorbeeld: kwadratische regressie in R<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we de relatie willen begrijpen tussen het aantal gewerkte uren en het gerapporteerde geluk. We hebben de volgende gegevens over het aantal gewerkte uren per week en het gerapporteerde geluksniveau (op een schaal van 0 tot 100) voor 11 verschillende mensen:<\/span> <\/p>\n<p data-slot-rendered-dynamic=\"true\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-6954 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadti1.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"150\" height=\"248\"><\/p>\n<p> <span style=\"color: #000000;\">Gebruik de volgende stappen om een kwadratisch regressiemodel in R te fitten.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Stap 1: Voer de gegevens in.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Eerst maken we een dataframe met onze gegevens:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#createdata<\/span>\ndata &lt;- data.frame(hours=c(6, 9, 12, 14, 30, 35, 40, 47, 51, 55, 60),\n                   happiness=c(14, 28, 50, 70, 89, 94, 90, 75, 59, 44, 27))\n<span style=\"color: #008080;\">\n#viewdata<\/span> \ndata\n\n   hours happiness\n1 6 14\n2 9 28\n3 12 50\n4 14 70\n5 30 89\n6 35 94\n7 40 90\n8 47 75\n9 51 59\n10 55 44\n11 60 27\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Stap 2: Visualiseer de gegevens.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Vervolgens zullen we een eenvoudig spreidingsdiagram maken om de gegevens te visualiseren.<\/span> <\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create scatterplot<\/span>\nplot(data$hours, data$happiness, pch=16)<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-8616 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadratiquer1.png\" alt=\"Spreidingsdiagram in R\" width=\"370\" height=\"336\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">We kunnen duidelijk zien dat de gegevens geen lineair patroon volgen.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Stap 3: Pas een eenvoudig lineair regressiemodel toe.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Vervolgens passen we een eenvoudig lineair regressiemodel toe om te zien hoe goed het bij de gegevens past:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#fit linear model<\/span>\nlinearModel &lt;- lm(happiness ~ hours, data=data)\n\n<span style=\"color: #008080;\">#view model summary<\/span>\nsummary(linearModel)\n\nCall:\nlm(formula = happiness ~ hours)\n\nResiduals:\n   Min 1Q Median 3Q Max \n-39.34 -21.99 -2.03 23.50 35.11 \n\nCoefficients:\n            Estimate Std. Error t value Pr(&gt;|t|)  \n(Intercept) 48.4531 17.3288 2.796 0.0208 *\nhours 0.2981 0.4599 0.648 0.5331  \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 28.72 on 9 degrees of freedom\nMultiple R-squared: 0.0446, Adjusted R-squared: -0.06156 \nF-statistic: 0.4201 on 1 and 9 DF, p-value: 0.5331\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De totale variantie in geluk die door het model wordt verklaard, bedraagt slechts <strong>4,46%<\/strong> , zoals blijkt uit de meervoudige R-kwadraatwaarde.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Stap 4: Pas een kwadratisch regressiemodel toe.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Vervolgens passen we een kwadratisch regressiemodel toe.<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create a new variable for hours <sup>2<\/sup><\/span>\ndata$hours2 &lt;- data$hours^2\n\n<span style=\"color: #008080;\">#fit quadratic regression model<\/span>\nquadraticModel &lt;- lm(happiness ~ hours + hours2, data=data)\n\n<span style=\"color: #008080;\">#view model summary\n<\/span>summary(quadraticModel)\n\nCall:\nlm(formula = happiness ~ hours + hours2, data = data)\n\nResiduals:\n    Min 1Q Median 3Q Max \n-6.2484 -3.7429 -0.1812 1.1464 13.6678 \n\nCoefficients:\n             Estimate Std. Error t value Pr(&gt;|t|)    \n(Intercept) -18.25364 6.18507 -2.951 0.0184 *  \nhours 6.74436 0.48551 13.891 6.98e-07 ***\nhours2 -0.10120 0.00746 -13.565 8.38e-07 ***\n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 6.218 on 8 degrees of freedom\nMultiple R-squared: 0.9602, Adjusted R-squared: 0.9502 \nF-statistic: 96.49 on 2 and 8 DF, p-value: 2.51e-06\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De totale variantie in geluk die door het model wordt verklaard, nam toe tot <b>96,02%<\/b> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen de volgende code gebruiken om te visualiseren hoe goed het model bij de gegevens past:<\/span> <\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create sequence of hour values<\/span>\nhourValues &lt;- seq(0, 60, 0.1)\n\n<span style=\"color: #008080;\">#create list of predicted happiness levels using quadratic model\n<\/span>happinessPredict &lt;- predict(quadraticModel, list(hours=hourValues, hours2=hourValues^2))\n\n<span style=\"color: #008080;\">#create scatterplot of original data values\n<\/span>plot(data$hours, data$happiness, pch=16)\n<span style=\"color: #008080;\">#add predicted lines based on quadratic regression model<\/span>\nlines(hourValues, happinessPredict, col='blue')\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-8619 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadratiquer2.png\" alt=\"Kwadratische regressiespreidingsdiagram in R\" width=\"399\" height=\"368\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">We kunnen zien dat de kwadratische regressielijn redelijk goed bij de gegevenswaarden past.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Stap 5: Interpreteer het kwadratische regressiemodel.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">In de vorige stap zagen we dat het resultaat van het kwadratische regressiemodel was:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong>Coefficients:\n             Estimate Std. Error t value Pr(&gt;|t|)    \n(Intercept) -18.25364 6.18507 -2.951 0.0184 *  \nhours 6.74436 0.48551 13.891 6.98e-07 ***\nhours2 -0.10120 0.00746 -13.565 8.38e-07 ***\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Op basis van de hier gepresenteerde co\u00ebffici\u00ebnten zou de aangepaste kwadratische regressie zijn:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Geluk = -0,1012 (uren) <sup>2<\/sup> + 6,7444 (uren) \u2013 18,2536<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen deze vergelijking gebruiken om het voorspelde geluk van een individu te vinden, gegeven het aantal uren dat hij of zij per week werkt.<\/span><\/p>\n<p data-slot-rendered-dynamic=\"true\"> <span style=\"color: #000000;\">Een persoon die bijvoorbeeld 60 uur per week werkt, zou een geluksniveau van <strong>22,09<\/strong> hebben:<\/span><\/p>\n<p data-slot-rendered-dynamic=\"true\"> <span style=\"color: #000000;\">Geluk = -0,1012(60) <sup>2<\/sup> + 6,7444(60) \u2013 18,2536 = 22,09<\/span><\/p>\n<p> <span style=\"color: #000000;\">Omgekeerd zou iemand die 30 uur per week werkt een geluksniveau van <strong>92,99<\/strong> moeten hebben:<\/span><\/p>\n<p> <span style=\"color: #000000;\">Geluk = -0,1012(30) <sup>2<\/sup> + 6,7444(30) \u2013 18,2536 = 92,99<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wanneer twee variabelen een lineair verband hebben, kunnen we vaak eenvoudige lineaire regressie gebruiken om hun verband te kwantificeren. Wanneer twee variabelen echter een kwadratische relatie hebben, kunnen we kwadratische regressie gebruiken om hun relatie te kwantificeren. In deze tutorial wordt uitgelegd hoe u kwadratische regressie uitvoert in R. Voorbeeld: kwadratische regressie in R Stel [&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-783","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 kwadratische regressie uit te voeren in R - Statorials<\/title>\n<meta name=\"description\" content=\"Een eenvoudige uitleg over het uitvoeren van kwadratische regressie in R, 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\/kwadratische-regressie-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe kwadratische regressie uit te voeren in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"Een eenvoudige uitleg over het uitvoeren van kwadratische regressie in R, inclusief een stapsgewijs voorbeeld.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T18:44:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadregstata1.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=\"3\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/\",\"name\":\"Hoe kwadratische regressie uit te voeren in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-28T18:44:38+00:00\",\"dateModified\":\"2023-07-28T18:44:38+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"Een eenvoudige uitleg over het uitvoeren van kwadratische regressie in R, inclusief een stapsgewijs voorbeeld.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe kwadratische regressie uit te voeren 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 kwadratische regressie uit te voeren in R - Statorials","description":"Een eenvoudige uitleg over het uitvoeren van kwadratische regressie in R, 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\/kwadratische-regressie-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe kwadratische regressie uit te voeren in R - Statorials","og_description":"Een eenvoudige uitleg over het uitvoeren van kwadratische regressie in R, inclusief een stapsgewijs voorbeeld.","og_url":"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/","og_site_name":"Statorials","article_published_time":"2023-07-28T18:44:38+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/quadregstata1.png"}],"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\/kwadratische-regressie-r\/","url":"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/","name":"Hoe kwadratische regressie uit te voeren in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-28T18:44:38+00:00","dateModified":"2023-07-28T18:44:38+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"Een eenvoudige uitleg over het uitvoeren van kwadratische regressie in R, inclusief een stapsgewijs voorbeeld.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/kwadratische-regressie-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe kwadratische regressie uit te voeren 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\/783","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=783"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/783\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}