{"id":1114,"date":"2023-07-27T15:08:14","date_gmt":"2023-07-27T15:08:14","guid":{"rendered":"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/"},"modified":"2023-07-27T15:08:14","modified_gmt":"2023-07-27T15:08:14","slug":"autocorrelatie-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/","title":{"rendered":"Hoe autocorrelatie in r te berekenen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><strong>Autocorrelatie<\/strong> meet de mate van gelijkenis tussen een tijdreeks en een vertraagde versie van zichzelf over opeenvolgende tijdsintervallen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het wordt ook wel &#8217;seri\u00eble correlatie&#8216; of &#8218;vertraagde correlatie&#8216; genoemd omdat het de relatie meet tussen de huidige waarden van een variabele en zijn historische waarden.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Wanneer de autocorrelatie in een tijdreeks hoog is, wordt het eenvoudig om toekomstige waarden te voorspellen door simpelweg naar waarden uit het verleden te verwijzen.<\/span><\/p>\n<h3> <strong>Hoe autocorrelatie in R te berekenen<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we de volgende tijdreeksen in R hebben die de waarde van een bepaalde variabele voor 15 verschillende perioden weergeven:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define data<\/span>\nx &lt;- c(22, 24, 25, 25, 28, 29, 34, 37, 40, 44, 51, 48, 47, 50, 51)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de autocorrelatie voor elke vertraging in de tijdreeks berekenen met behulp van de <strong>acf()-<\/strong> functie uit de <strong>tseries-<\/strong> bibliotheek:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #107d3f;\"><span style=\"color: #993300;\">library<\/span> <span style=\"color: #000000;\">(tseries)<\/span>\n<\/span><\/span>\n<span style=\"color: #008080;\">#calculate autocorrelations<\/span>\nacf(x, pl= <span style=\"color: #008000;\">FALSE<\/span> )\n\n     0 1 2 3 4 5 6 7 8 9 10 \n 1.000 0.832 0.656 0.491 0.279 0.031 -0.165 -0.304 -0.401 -0.458 -0.450 \n    11 \n-0.369 \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 autocorrelatie bij lag 0 is <strong>1<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De autocorrelatie bij lag 1 is <strong>0,832<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De autocorrelatie bij lag 2 is <strong>0,656<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De autocorrelatie bij lag 3 is <strong>0,491<\/strong> .<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Enzovoort.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen ook het aantal vertragingen specificeren dat moet worden weergegeven met het <strong>lag-<\/strong> argument:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate autocorrelations up to lag=5<\/span>\nacf(x, lag=5, pl= <span style=\"color: #008000;\">FALSE<\/span> )\n\nAutocorrelations of series 'x', by lag\n\n    0 1 2 3 4 5 \n1.000 0.832 0.656 0.491 0.279 0.031<\/strong><\/pre>\n<h3> <strong>Hoe de autocorrelatiefunctie in R te plotten<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">We kunnen de autocorrelatiefunctie voor een tijdreeks in R plotten door simpelweg het <strong>pl=FALSE-<\/strong> argument niet te gebruiken:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#plot autocorrelation function\n<\/span>acf(x)\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11307 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/autocorrelationr1.png\" alt=\"Autocorrelatie in R\" width=\"428\" height=\"435\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Op de x-as wordt het aantal vertragingen weergegeven en op de y-as de autocorrelatie bij dat aantal vertragingen. Standaard begint de plot bij lag = 0 en is de autocorrelatie altijd <strong>1<\/strong> bij lag = 0.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Je kunt ook een andere titel voor de plot opgeven met behulp van het <strong>hoofdargument<\/strong> :<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#plot autocorrelation function with custom title\n<\/span>acf(x, main=' <span style=\"color: #008000;\">Autocorrelation by Lag<\/span> ')<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11309 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/autocorrelationr2.png\" alt=\"Autocorrelatieplot in R\" width=\"437\" height=\"430\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/nl\/autocorrelatie-python\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe autocorrelatie in Python te berekenen<\/a><br \/><a href=\"https:\/\/statorials.org\/nl\/excel-autocorrelatie\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe autocorrelatie in Excel te berekenen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Autocorrelatie meet de mate van gelijkenis tussen een tijdreeks en een vertraagde versie van zichzelf over opeenvolgende tijdsintervallen. Het wordt ook wel &#8217;seri\u00eble correlatie&#8216; of &#8218;vertraagde correlatie&#8216; genoemd omdat het de relatie meet tussen de huidige waarden van een variabele en zijn historische waarden. Wanneer de autocorrelatie in een tijdreeks hoog is, wordt het eenvoudig [&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-1114","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 autocorrelatie te berekenen in R - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u autocorrelatie 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\/autocorrelatie-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe autocorrelatie te berekenen in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u autocorrelatie in R kunt berekenen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T15:08:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/autocorrelationr1.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\/autocorrelatie-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/\",\"name\":\"Hoe autocorrelatie te berekenen in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-27T15:08:14+00:00\",\"dateModified\":\"2023-07-27T15:08:14+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u autocorrelatie in R kunt berekenen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe autocorrelatie 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 autocorrelatie te berekenen in R - Statorials","description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u autocorrelatie 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\/autocorrelatie-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe autocorrelatie te berekenen in R - Statorials","og_description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u autocorrelatie in R kunt berekenen.","og_url":"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-27T15:08:14+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/autocorrelationr1.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\/autocorrelatie-in-r\/","url":"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/","name":"Hoe autocorrelatie te berekenen in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-27T15:08:14+00:00","dateModified":"2023-07-27T15:08:14+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u autocorrelatie in R kunt berekenen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/autocorrelatie-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe autocorrelatie 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\/1114","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=1114"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1114\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}