{"id":2946,"date":"2023-07-19T23:21:19","date_gmt":"2023-07-19T23:21:19","guid":{"rendered":"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/"},"modified":"2023-07-19T23:21:19","modified_gmt":"2023-07-19T23:21:19","slug":"prever-regressao-multipla-em-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/","title":{"rendered":"Como prever valores em r usando um modelo de regress\u00e3o m\u00faltipla"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><span style=\"color: #000000;\">Voc\u00ea pode usar a seguinte sintaxe b\u00e1sica para prever valores em R usando um modelo de regress\u00e3o linear m\u00faltipla ajustado:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define new observation\n<\/span>new &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (x1=c(5), x2=c(10), x3=c(12.5))\n\n<span style=\"color: #008080;\">#use fitted model to predict the response value for the new observation\n<\/span>predict(model, newdata=new)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">O exemplo a seguir mostra como usar esta fun\u00e7\u00e3o na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo: previs\u00e3o de valores usando um modelo de regress\u00e3o linear m\u00faltipla ajustado<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Suponha que temos o seguinte conjunto de dados em R que cont\u00e9m informa\u00e7\u00f5es sobre jogadores de basquete:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (rating=c(67, 75, 79, 85, 90, 96, 97),\n                 points=c(8, 12, 16, 15, 22, 28, 24),\n                 assists=c(4, 6, 6, 5, 3, 8, 7),\n                 rebounds=c(1, 4, 3, 3, 2, 6, 7))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n  rating points assists rebounds\n1 67 8 4 1\n2 75 12 6 4\n3 79 16 6 3\n4 85 15 5 3\n5 90 22 3 2\n6 96 28 8 6\n7 97 24 7 7\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Agora, suponha que ajustamos um modelo de regress\u00e3o linear m\u00faltipla usando <strong>pontos<\/strong> , <strong>assist\u00eancias<\/strong> e <strong>rebotes<\/strong> como vari\u00e1veis preditoras e <strong>classifica\u00e7\u00e3o<\/strong> como <a href=\"https:\/\/statorials.org\/pt\/respostas-explicativas-das-variaveis\/\" target=\"_blank\" rel=\"noopener\">vari\u00e1vel de resposta<\/a> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#fit multiple linear regression model\n<\/span>model &lt;- lm(rating ~ points + assists + rebounds, data=df)\n\n<span style=\"color: #008080;\">#view model summary\n<\/span>summary(model)\n\nCall:\nlm(formula = rating ~ points + assists + rebounds, data = df)\n\nResiduals:\n      1 2 3 4 5 6 7 \n-1.5902 -1.7181 0.2413 4.8597 -1.0201 -0.6082 -0.1644 \n\nCoefficients:\n            Estimate Std. Error t value Pr(&gt;|t|)   \n(Intercept) 66.4355 6.6932 9.926 0.00218 **\npoints 1.2152 0.2788 4.359 0.02232 * \nassists -2.5968 1.6263 -1.597 0.20860   \nrebounds 2.8202 1.6118 1.750 0.17847   \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 3.193 on 3 degrees of freedom\nMultiple R-squared: 0.9589, Adjusted R-squared: 0.9179 \nF-statistic: 23.35 on 3 and 3 DF, p-value: 0.01396\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">A partir dos valores da coluna <strong>Estimativa<\/strong> , podemos escrever o modelo de regress\u00e3o ajustado:<\/span><\/p>\n<p> <span style=\"color: #000000;\">Pontua\u00e7\u00e3o = 66,4355 + 1,2151 (pontos) \u2013 2,5968 (assist\u00eancias) + 2,8202 (rebotes)<\/span><\/p>\n<p> <span style=\"color: #000000;\">Podemos usar o seguinte c\u00f3digo para prever a classifica\u00e7\u00e3o de um novo jogador que tenha 20 pontos, 5 assist\u00eancias e 2 rebotes:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define new player\n<\/span>new &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (points=c(20), assists=c(5), rebounds=c(2))\n\n<span style=\"color: #008080;\">#use the fitted model to predict the rating for the new player\n<\/span>predict(model, newdata=new)\n\n       1 \n83.39607 \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">O modelo prev\u00ea que este novo jogador ter\u00e1 uma classifica\u00e7\u00e3o de <strong>83,39607<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Podemos confirmar que isso est\u00e1 correto inserindo os valores do novo jogador na equa\u00e7\u00e3o de regress\u00e3o ajustada:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Pontua\u00e7\u00e3o = 66,4355 + 1,2151 (pontos) \u2013 2,5968 (assist\u00eancias) + 2,8202 (rebotes)<\/span><\/li>\n<li> <span style=\"color: #000000;\">Avalia\u00e7\u00e3o = 66,4355 + 1,2151(20) \u2013 2,5968(5) + 2,8202(2)<\/span><\/li>\n<li> <span style=\"color: #000000;\">Pontua\u00e7\u00e3o = 83,39<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Isso corresponde ao valor que calculamos usando a fun\u00e7\u00e3o <strong>prever()<\/strong> em R.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h3>\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\/regressao-linear-simples-em-r\/\" target=\"_blank\" rel=\"noopener\">Como realizar regress\u00e3o linear simples em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/regressao-linear-multipla-r\/\" target=\"_blank\" rel=\"noopener\">Como realizar regress\u00e3o linear m\u00faltipla em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/traco-residual-r\/\" target=\"_blank\" rel=\"noopener\">Como criar um gr\u00e1fico residual em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar a seguinte sintaxe b\u00e1sica para prever valores em R usando um modelo de regress\u00e3o linear m\u00faltipla ajustado: #define new observation new &lt;- data. frame (x1=c(5), x2=c(10), x3=c(12.5)) #use fitted model to predict the response value for the new observation predict(model, newdata=new) O exemplo a seguir mostra como usar esta fun\u00e7\u00e3o na pr\u00e1tica. [&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-2946","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 prever valores em R usando um modelo de regress\u00e3o m\u00faltipla \u2013 Estatologia<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como prever novos valores em R usando um modelo de regress\u00e3o m\u00faltipla ajustado, com um exemplo.\" \/>\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\/prever-regressao-multipla-em-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como prever valores em R usando um modelo de regress\u00e3o m\u00faltipla \u2013 Estatologia\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como prever novos valores em R usando um modelo de regress\u00e3o m\u00faltipla ajustado, com um exemplo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T23:21:19+00:00\" \/>\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\/prever-regressao-multipla-em-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/\",\"name\":\"Como prever valores em R usando um modelo de regress\u00e3o m\u00faltipla \u2013 Estatologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-19T23:21:19+00:00\",\"dateModified\":\"2023-07-19T23:21:19+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como prever novos valores em R usando um modelo de regress\u00e3o m\u00faltipla ajustado, com um exemplo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como prever valores em r usando um modelo de regress\u00e3o m\u00faltipla\"}]},{\"@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 prever valores em R usando um modelo de regress\u00e3o m\u00faltipla \u2013 Estatologia","description":"Este tutorial explica como prever novos valores em R usando um modelo de regress\u00e3o m\u00faltipla ajustado, com um exemplo.","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\/prever-regressao-multipla-em-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como prever valores em R usando um modelo de regress\u00e3o m\u00faltipla \u2013 Estatologia","og_description":"Este tutorial explica como prever novos valores em R usando um modelo de regress\u00e3o m\u00faltipla ajustado, com um exemplo.","og_url":"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/","og_site_name":"Statorials","article_published_time":"2023-07-19T23:21:19+00:00","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\/prever-regressao-multipla-em-r\/","url":"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/","name":"Como prever valores em R usando um modelo de regress\u00e3o m\u00faltipla \u2013 Estatologia","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-19T23:21:19+00:00","dateModified":"2023-07-19T23:21:19+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como prever novos valores em R usando um modelo de regress\u00e3o m\u00faltipla ajustado, com um exemplo.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/prever-regressao-multipla-em-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como prever valores em r usando um modelo de regress\u00e3o m\u00faltipla"}]},{"@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\/2946","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=2946"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2946\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=2946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=2946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=2946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}