{"id":2659,"date":"2023-07-21T07:21:55","date_gmt":"2023-07-21T07:21:55","guid":{"rendered":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/"},"modified":"2023-07-21T07:21:55","modified_gmt":"2023-07-21T07:21:55","slug":"teste-kpss-em-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/","title":{"rendered":"Como realizar um teste kpss em r (incluindo um exemplo)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Um <strong>teste KPSS<\/strong> pode ser usado para determinar se uma s\u00e9rie temporal tem uma tend\u00eancia estacion\u00e1ria.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Este teste utiliza a seguinte hip\u00f3tese nula e alternativa:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>H <sub>0<\/sub><\/strong> : A s\u00e9rie temporal tem tend\u00eancia estacion\u00e1ria.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong><sub>HA<\/sub><\/strong> : A s\u00e9rie temporal <em>n\u00e3o tem<\/em> tend\u00eancia estacion\u00e1ria.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Se o <a href=\"https:\/\/statorials.org\/pt\/p-valores-significancia-estatistica\/\" target=\"_blank\" rel=\"noopener\">valor p<\/a> do teste estiver abaixo de um determinado n\u00edvel de signific\u00e2ncia (ex. \u03b1 = 0,05), ent\u00e3o rejeitamos a hip\u00f3tese nula e conclu\u00edmos que a s\u00e9rie temporal n\u00e3o possui tend\u00eancia estacion\u00e1ria.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Caso contr\u00e1rio, n\u00e3o conseguiremos rejeitar a hip\u00f3tese nula.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como realizar um teste KPSS em R.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 1: teste KPSS em R (com dados estacion\u00e1rios)<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Primeiro, vamos criar alguns dados falsos em R para trabalhar:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible\n<span style=\"color: #000000;\">set. <span style=\"color: #3366ff;\">seeds<\/span> (100)\n\n<span style=\"color: #008080;\">#create time series data\n<\/span>data&lt;-rnorm(100)\n\n<span style=\"color: #008080;\">#plot time series data as line plot\n<\/span>plot(data, type=' <span style=\"color: #ff0000;\">l<\/span> ')<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-23441 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kpss1.jpg\" alt=\"\" width=\"441\" height=\"404\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>kpss.test()<\/strong> do pacote <strong>tseries<\/strong> para realizar um teste KPSS nestes dados de s\u00e9rie temporal:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (tseries)\n\n<span style=\"color: #008080;\">#perform KPSS test<\/span>\nkpss. <span style=\"color: #3366ff;\">test<\/span> (data, null=\" <span style=\"color: #008000;\">Trend<\/span> \")\n\n\tKPSS Test for Trend Stationarity\n\ndata:data\nKPSS Trend = 0.034563, Truncation lag parameter = 4, p-value = 0.1\n\nWarning message:\nIn kpss.test(data, null = \"Trend\"): p-value greater than printed p-value\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">O valor p \u00e9 <strong>0,1<\/strong> . Como este valor n\u00e3o \u00e9 inferior a 0,05, n\u00e3o rejeitamos a hip\u00f3tese nula do teste KPSS.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Isso significa que podemos assumir que a s\u00e9rie temporal tem uma tend\u00eancia estacion\u00e1ria.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : O valor p ainda \u00e9 maior que 0,1, mas o valor mais baixo que a fun\u00e7\u00e3o kpss.test() produzir\u00e1 \u00e9 0,1.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 2: teste KPSS em R (com dados n\u00e3o estacion\u00e1rios)<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Primeiro, vamos criar alguns dados falsos em R para trabalhar:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible<span style=\"color: #000000;\">\n\n<span style=\"color: #008080;\">#create time series data\n<\/span>data &lt;-c(0, 3, 4, 3, 6, 7, 5, 8, 15, 13, 19, 12, 29, 15, 45, 23, 67, 45)\n\n<span style=\"color: #008080;\">#plot time series data as line plot\n<\/span>plot(data, type=' <span style=\"color: #ff0000;\">l<\/span> ')<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-23443 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kpss2.jpg\" alt=\"\" width=\"408\" height=\"369\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Novamente, podemos usar a fun\u00e7\u00e3o <strong>kpss.test()<\/strong> do pacote <strong>tseries<\/strong> para realizar um teste KPSS nestes dados de s\u00e9rie temporal:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (tseries)\n\n<span style=\"color: #008080;\">#perform KPSS test<\/span>\nkpss. <span style=\"color: #3366ff;\">test<\/span> (data, null=\" <span style=\"color: #008000;\">Trend<\/span> \")\n\n\tKPSS Test for Trend Stationarity\n\ndata:data\nKPSS Trend = 0.149, Truncation lag parameter = 2, p-value = 0.04751<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">O valor p \u00e9 <strong>0,04751<\/strong> . Sendo este valor inferior a 0,05, rejeitamos a hip\u00f3tese nula do teste KPSS.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Isso significa que a s\u00e9rie temporal <em>n\u00e3o \u00e9<\/em> estacion\u00e1ria.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><span style=\"color: #000000;\"><br \/><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir fornecem informa\u00e7\u00f5es adicionais sobre como trabalhar com dados de s\u00e9rie temporal em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/tracar-series-temporais-em-r\/\" target=\"_blank\" rel=\"noopener\">Como tra\u00e7ar uma s\u00e9rie temporal em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/teste-dickey-fuller-em-r\/\" target=\"_blank\" rel=\"noopener\">Como realizar um teste Dickey-Fuller aumentado em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Um teste KPSS pode ser usado para determinar se uma s\u00e9rie temporal tem uma tend\u00eancia estacion\u00e1ria. Este teste utiliza a seguinte hip\u00f3tese nula e alternativa: H 0 : A s\u00e9rie temporal tem tend\u00eancia estacion\u00e1ria. HA : A s\u00e9rie temporal n\u00e3o tem tend\u00eancia estacion\u00e1ria. Se o valor p do teste estiver abaixo de um determinado n\u00edvel [&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-2659","post","type-post","status-publish","format-standard","hentry","category-guia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Como realizar um teste KPSS em R (com exemplo) - Statorials<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como realizar um teste KPSS em R, com um exemplo completo.\" \/>\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\/pt\/teste-kpss-em-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como realizar um teste KPSS em R (com exemplo) - Statorials\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como realizar um teste KPSS em R, com um exemplo completo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-21T07:21:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kpss1.jpg\" \/>\n<meta name=\"author\" content=\"Dr. benjamim anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. benjamim anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/\",\"name\":\"Como realizar um teste KPSS em R (com exemplo) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-21T07:21:55+00:00\",\"dateModified\":\"2023-07-21T07:21:55+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como realizar um teste KPSS em R, com um exemplo completo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como realizar um teste kpss em r (incluindo um exemplo)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pt\/#website\",\"url\":\"https:\/\/statorials.org\/pt\/\",\"name\":\"Statorials\",\"description\":\"O seu guia para a literacia estat\u00edstica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pt\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\",\"name\":\"Dr. benjamim anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. benjamim anderson\"},\"description\":\"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais\",\"sameAs\":[\"https:\/\/statorials.org\/pt\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Como realizar um teste KPSS em R (com exemplo) - Statorials","description":"Este tutorial explica como realizar um teste KPSS em R, com um exemplo completo.","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\/pt\/teste-kpss-em-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como realizar um teste KPSS em R (com exemplo) - Statorials","og_description":"Este tutorial explica como realizar um teste KPSS em R, com um exemplo completo.","og_url":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/","og_site_name":"Statorials","article_published_time":"2023-07-21T07:21:55+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kpss1.jpg"}],"author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/","url":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/","name":"Como realizar um teste KPSS em R (com exemplo) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-21T07:21:55+00:00","dateModified":"2023-07-21T07:21:55+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como realizar um teste KPSS em R, com um exemplo completo.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/teste-kpss-em-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/teste-kpss-em-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como realizar um teste kpss em r (incluindo um exemplo)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pt\/#website","url":"https:\/\/statorials.org\/pt\/","name":"Statorials","description":"O seu guia para a literacia estat\u00edstica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pt\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-PT"},{"@type":"Person","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666","name":"Dr. benjamim anderson","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr. benjamim anderson"},"description":"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais","sameAs":["https:\/\/statorials.org\/pt"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/comments?post=2659"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2659\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=2659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=2659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=2659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}