{"id":4490,"date":"2023-07-10T16:58:21","date_gmt":"2023-07-10T16:58:21","guid":{"rendered":"https:\/\/statorials.org\/pt\/fitdistr-r\/"},"modified":"2023-07-10T16:58:21","modified_gmt":"2023-07-10T16:58:21","slug":"fitdistr-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/fitdistr-r\/","title":{"rendered":"Como usar fitdistr() em r para ajustar distribui\u00e7\u00f5es"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar a fun\u00e7\u00e3o <strong>fitdistr()<\/strong> do pacote <strong>MASS<\/strong> em R para estimar os par\u00e2metros de uma distribui\u00e7\u00e3o maximizando a fun\u00e7\u00e3o de verossimilhan\u00e7a.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>fitdistr(x, densofun,\u2026)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Ouro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>x<\/strong> : Um vetor num\u00e9rico representando os valores da distribui\u00e7\u00e3o<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>Densefun<\/strong> : a distribui\u00e7\u00e3o para estimar os par\u00e2metros para<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Observe que o argumento <strong>densofun<\/strong> aceita os seguintes nomes de distribui\u00e7\u00e3o potencial: <strong>beta<\/strong> , <strong>cauchy<\/strong> , <strong>qui-quadrado<\/strong> , <strong>exponencial<\/strong> , <strong>gama<\/strong> , <strong>geom\u00e9trica<\/strong> , <strong>lognormal<\/strong> , <strong>log\u00edstica<\/strong> , <strong>binomial negativo<\/strong> , <strong>normal<\/strong> , <strong>Poisson<\/strong> , <strong>t<\/strong> e <strong>Weibull<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">O exemplo a seguir mostra como usar a fun\u00e7\u00e3o <strong>fitdistr()<\/strong> na pr\u00e1tica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Exemplo: como usar a fun\u00e7\u00e3o fitdistr() para ajustar distribui\u00e7\u00f5es em R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Suponha que usemos a fun\u00e7\u00e3o <strong>rnorm()<\/strong> em R para gerar um vetor de 200 valores que segue uma distribui\u00e7\u00e3o normal:<\/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> (1)<\/span>\n\n#generate sample of 200 observations that follows normal dist with mean=10 and sd=3<\/span>\ndata &lt;- rnorm(200, mean=10, sd=3)\n\n<span style=\"color: #008080;\">#view first 6 observations in sample\n<\/span>head(data)\n\n[1] 8.120639 10.550930 7.493114 14.785842 10.988523 7.538595\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>hist()<\/strong> para criar um histograma para visualizar a distribui\u00e7\u00e3o dos valores dos dados:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\">hist(data, col=' <span style=\"color: #ff0000;\">steelblue<\/span> ')\n<\/span><\/span><\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11442 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistr1.png\" alt=\"Gere uma distribui\u00e7\u00e3o normal em R\" width=\"452\" height=\"451\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Podemos ver que os dados realmente parecem distribu\u00eddos normalmente.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Podemos ent\u00e3o usar a fun\u00e7\u00e3o <strong>fitdistr()<\/strong> para estimar os par\u00e2metros desta distribui\u00e7\u00e3o:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">library<\/span> (MASS)\n\n<\/span>#estimate parameters of distribution\n<span style=\"color: #000000;\">fitdistr(data, \u201c <span style=\"color: #ff0000;\">normal<\/span> \u201d)\n\n      mean sd    \n  10.1066189 2.7803148 \n (0.1965979) (0.1390157)\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">A fun\u00e7\u00e3o <strong>fitdistr()<\/strong> estima que o vetor de valores segue uma <a href=\"https:\/\/statorials.org\/pt\/a-distribuicao-normal\/\" target=\"_blank\" rel=\"noopener\">distribui\u00e7\u00e3o normal<\/a> com m\u00e9dia de <strong>10,1066189<\/strong> e desvio padr\u00e3o de <strong>2,7803148<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esses valores n\u00e3o devem ser surpreendentes, pois geramos os dados usando a fun\u00e7\u00e3o <strong>rnorm()<\/strong> com valor m\u00e9dio de 10 e desvio padr\u00e3o de 3.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir explicam como realizar outras tarefas comuns em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/tracar-a-distribuicao-normal-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Como tra\u00e7ar uma distribui\u00e7\u00e3o normal em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/gerar-uma-distribuicao-normal-em-r\/\" target=\"_blank\" rel=\"noopener\">Como gerar uma distribui\u00e7\u00e3o normal em R<\/a><br \/><a href=\"https:\/\/statorials.org\/pt\/teste-shapiro-wilk-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Como realizar um teste de Shapiro-Wilk para normalidade em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar a fun\u00e7\u00e3o fitdistr() do pacote MASS em R para estimar os par\u00e2metros de uma distribui\u00e7\u00e3o maximizando a fun\u00e7\u00e3o de verossimilhan\u00e7a. Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica: fitdistr(x, densofun,\u2026) Ouro: x : Um vetor num\u00e9rico representando os valores da distribui\u00e7\u00e3o Densefun : a distribui\u00e7\u00e3o para estimar os par\u00e2metros para Observe que o [&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-4490","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 usar fitdistr() em R para ajustar distribui\u00e7\u00f5es \u2013 Estatologia<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o fitdistr() em R para ajustar distribui\u00e7\u00f5es, incluindo exemplos.\" \/>\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\/fitdistr-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como usar fitdistr() em R para ajustar distribui\u00e7\u00f5es \u2013 Estatologia\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o fitdistr() em R para ajustar distribui\u00e7\u00f5es, incluindo exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/fitdistr-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-10T16:58:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistr1.png\" \/>\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\/fitdistr-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/fitdistr-r\/\",\"name\":\"Como usar fitdistr() em R para ajustar distribui\u00e7\u00f5es \u2013 Estatologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-10T16:58:21+00:00\",\"dateModified\":\"2023-07-10T16:58:21+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como usar a fun\u00e7\u00e3o fitdistr() em R para ajustar distribui\u00e7\u00f5es, incluindo exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/fitdistr-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/fitdistr-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/fitdistr-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como usar fitdistr() em r para ajustar distribui\u00e7\u00f5es\"}]},{\"@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 usar fitdistr() em R para ajustar distribui\u00e7\u00f5es \u2013 Estatologia","description":"Este tutorial explica como usar a fun\u00e7\u00e3o fitdistr() em R para ajustar distribui\u00e7\u00f5es, incluindo exemplos.","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\/fitdistr-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como usar fitdistr() em R para ajustar distribui\u00e7\u00f5es \u2013 Estatologia","og_description":"Este tutorial explica como usar a fun\u00e7\u00e3o fitdistr() em R para ajustar distribui\u00e7\u00f5es, incluindo exemplos.","og_url":"https:\/\/statorials.org\/pt\/fitdistr-r\/","og_site_name":"Statorials","article_published_time":"2023-07-10T16:58:21+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/normaldistr1.png"}],"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\/fitdistr-r\/","url":"https:\/\/statorials.org\/pt\/fitdistr-r\/","name":"Como usar fitdistr() em R para ajustar distribui\u00e7\u00f5es \u2013 Estatologia","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-10T16:58:21+00:00","dateModified":"2023-07-10T16:58:21+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como usar a fun\u00e7\u00e3o fitdistr() em R para ajustar distribui\u00e7\u00f5es, incluindo exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/fitdistr-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/fitdistr-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/fitdistr-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como usar fitdistr() em r para ajustar distribui\u00e7\u00f5es"}]},{"@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\/4490","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=4490"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/4490\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=4490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=4490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=4490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}