{"id":1557,"date":"2023-07-25T21:49:24","date_gmt":"2023-07-25T21:49:24","guid":{"rendered":"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/"},"modified":"2023-07-25T21:49:24","modified_gmt":"2023-07-25T21:49:24","slug":"kruiscorrelatie-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/","title":{"rendered":"Hoe kruiscorrelatie in r te berekenen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><strong>Kruiscorrelatie<\/strong> is een manier om de mate van gelijkenis tussen een tijdreeks en een vertraagde versie van een andere tijdreeks te meten.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dit type correlatie is handig om te berekenen, omdat het ons kan vertellen of waarden in de ene tijdreeks voorspellend zijn voor toekomstige waarden in een andere tijdreeks.<\/span> <span style=\"color: #000000;\">Met andere woorden, het kan ons vertellen of de ene tijdreeks een voorlopende indicator is voor een andere tijdreeks.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dit type correlatie wordt op veel verschillende gebieden gebruikt, waaronder:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Economie:<\/strong> De Consumer Confidence Index (CCI) wordt beschouwd als een voorlopende indicator van het bruto binnenlands product (bbp) van een land. Als de CCI bijvoorbeeld in een bepaalde maand hoog is, zal het bbp waarschijnlijk <em>x<\/em> maanden later hoger zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Bedrijven:<\/strong> Marketinguitgaven worden vaak beschouwd als een voorlopende indicator van toekomstige bedrijfsinkomsten. Als een bedrijf bijvoorbeeld in een kwartaal een ongewoon hoog bedrag aan marketing uitgeeft, dan zou de totale omzet <em>x<\/em> kwartalen later hoog moeten zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Biologie:<\/strong> De totale oceaanvervuiling wordt beschouwd als een voorlopende indicator van de populatie van een bepaalde soort schildpadden. Als de vervuiling bijvoorbeeld in een bepaald jaar hoger is, wordt verwacht dat de totale schildpaddenpopulatie <em>x<\/em> jaar later zal afnemen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld: Hoe kruiscorrelatie in R te berekenen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we de volgende tijdreeksen in R hebben die de totale marketinguitgaven (in duizenden) voor een bepaald bedrijf weergeven, evenals de totale inkomsten (in duizenden) gedurende 12 opeenvolgende maanden:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define data<\/span>\nmarketing &lt;- c(3, 4, 5, 5, 7, 9, 13, 15, 12, 10, 8, 8)\nrevenue &lt;- c(21, 19, 22, 24, 25, 29, 30, 34, 37, 40, 35, 30)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de kruiscorrelatie voor elke vertraging tussen de twee tijdreeksen als volgt berekenen met behulp van de <b>ccf()-<\/b> functie:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate cross correlation<\/span>\nccf(marketing, revenue)\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-15415 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/correlation-croiseer1.png\" alt=\"Kruiscorrelatie in R\" width=\"419\" height=\"423\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Deze grafiek toont de correlatie tussen de twee tijdreeksen met verschillende vertragingen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Om de werkelijke correlatiewaarden weer te geven, kunnen we de volgende syntaxis gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display cross correlation values<\/span>\n<span style=\"color: #3366ff;\">print<\/span> (ccf(marketing, revenue))\n\nAutocorrelations of series 'X', by lag\n\n    -7 -6 -5 -4 -3 -2 -1 0 1 2 3 \n-0.430 -0.351 -0.190 0.123 0.489 0.755 0.868 0.771 0.462 0.194 -0.061 \n     4 5 6 7 \n-0.282 -0.445 -0.492 -0.358\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">U kunt deze uitvoer als volgt interpreteren:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">De kruiscorrelatie bij lag 0 is <strong>0,771<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De kruiscorrelatie bij lag 1 is <strong>0,462<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De kruiscorrelatie bij lag 2 is <strong>0,194<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De kruiscorrelatie bij lag 3 is <strong>-0,061<\/strong> .<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Enzovoort.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Merk op dat de correlatie tussen de twee tijdreeksen vrij positief is, met vertragingen van -2 tot 2, wat ons vertelt dat marketinguitgaven in een bepaalde maand behoorlijk voorspellend zijn voor de omzet \u00e9\u00e9n en twee maanden later.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dit is intu\u00eftief logisch: we verwachten dat hoge marketinguitgaven in een bepaalde maand voorspellend zullen zijn voor een hogere omzet in de komende twee maanden.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe autocorrelatie in R te berekenen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/gedeeltelijke-correlatie-r\/\" target=\"_blank\" rel=\"noopener\">Hoe de gedeeltelijke correlatie in R te berekenen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/rollende-correlatie-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe de glijdende correlatie in R te berekenen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kruiscorrelatie is een manier om de mate van gelijkenis tussen een tijdreeks en een vertraagde versie van een andere tijdreeks te meten. Dit type correlatie is handig om te berekenen, omdat het ons kan vertellen of waarden in de ene tijdreeks voorspellend zijn voor toekomstige waarden in een andere tijdreeks. Met andere woorden, het kan [&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-1557","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 kruiscorrelatie in R - Statorials te berekenen<\/title>\n<meta name=\"description\" content=\"Deze tutorial legt aan de hand van verschillende voorbeelden uit hoe je de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.\" \/>\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\/kruiscorrelatie-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe kruiscorrelatie in R - Statorials te berekenen\" \/>\n<meta property=\"og:description\" content=\"Deze tutorial legt aan de hand van verschillende voorbeelden uit hoe je de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T21:49:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/correlation-croiseer1.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=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/\",\"name\":\"Hoe kruiscorrelatie in R - Statorials te berekenen\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-25T21:49:24+00:00\",\"dateModified\":\"2023-07-25T21:49:24+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"Deze tutorial legt aan de hand van verschillende voorbeelden uit hoe je de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe kruiscorrelatie in r 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 kruiscorrelatie in R - Statorials te berekenen","description":"Deze tutorial legt aan de hand van verschillende voorbeelden uit hoe je de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.","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\/kruiscorrelatie-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe kruiscorrelatie in R - Statorials te berekenen","og_description":"Deze tutorial legt aan de hand van verschillende voorbeelden uit hoe je de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.","og_url":"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-25T21:49:24+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/correlation-croiseer1.png"}],"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\/kruiscorrelatie-in-r\/","url":"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/","name":"Hoe kruiscorrelatie in R - Statorials te berekenen","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-25T21:49:24+00:00","dateModified":"2023-07-25T21:49:24+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"Deze tutorial legt aan de hand van verschillende voorbeelden uit hoe je de kruiscorrelatie tussen twee tijdreeksen in R kunt berekenen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/kruiscorrelatie-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe kruiscorrelatie in r 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\/1557","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=1557"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1557\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}