{"id":3904,"date":"2023-07-14T20:50:46","date_gmt":"2023-07-14T20:50:46","guid":{"rendered":"https:\/\/statorials.org\/pt\/hipotese-linear-r\/"},"modified":"2023-07-14T20:50:46","modified_gmt":"2023-07-14T20:50:46","slug":"hipotese-linear-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/hipotese-linear-r\/","title":{"rendered":"Como usar a fun\u00e7\u00e3o linearhypothesis() em r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar a fun\u00e7\u00e3o <strong>LinearHypothesis()<\/strong> do pacote <strong>car<\/strong> em R para testar hip\u00f3teses lineares em um modelo de regress\u00e3o espec\u00edfico.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>linearHypothesis(fit, c(\" <span style=\"color: #ff0000;\">var1=0<\/span> \", \" <span style=\"color: #ff0000;\">var2=0<\/span> \"))<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Este exemplo espec\u00edfico testa se os coeficientes de regress\u00e3o <strong>var1<\/strong> e <strong>var2<\/strong> no modelo denominado <strong>ajuste<\/strong> s\u00e3o conjuntamente iguais a zero.<\/span><\/p>\n<p> <span style=\"color: #000000;\">O exemplo a seguir mostra como usar esta fun\u00e7\u00e3o na pr\u00e1tica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Exemplo: como usar a fun\u00e7\u00e3o LinearHypothesis() em R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Suponha que temos o seguinte quadro de dados em R que mostra o n\u00famero de horas gastas estudando, o n\u00famero de exames pr\u00e1ticos realizados e a nota do exame final de 10 alunos em uma turma:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data.frame(score=c(77, 79, 84, 85, 88, 99, 95, 90, 92, 94),\n                 hours=c(1, 1, 2, 3, 2, 4, 4, 2, 3, 3),\n                 prac_exams=c(2, 4, 4, 2, 4, 5, 4, 3, 2, 1))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   score hours prac_exams\n1 77 1 2\n2 79 1 4\n3 84 2 4\n4 85 3 2\n5 88 2 4\n6 99 4 5\n7 95 4 4\n8 90 2 3\n9 92 3 2\n10 94 3 1\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Agora suponha que queiramos ajustar o seguinte modelo de regress\u00e3o linear m\u00faltipla em R:<\/span><\/p>\n<p> <span style=\"color: #000000;\">Nota do exame = \u03b2 <sub>0<\/sub> + \u03b2 <sub>1<\/sub> (horas) + \u03b2 <sub>2<\/sub> (exames pr\u00e1ticos)<\/span><\/p>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <a href=\"https:\/\/statorials.org\/pt\/funcao-lm-em-r\/\" target=\"_blank\" rel=\"noopener\">lm()<\/a> para adaptar este modelo:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#fit multiple linear regression model\n<\/span>fit &lt;- lm(score ~ hours + prac_exams, data=df)\n\n<span style=\"color: #008080;\">#view summary of model\n<\/span>summary(fit)\n\nCall:\nlm(formula = score ~ hours + prac_exams, data = df)\n\nResiduals:\n    Min 1Q Median 3Q Max \n-5.8366 -2.0875 0.1381 2.0652 4.6381 \n\nCoefficients:\n            Estimate Std. Error t value Pr(&gt;|t|)    \n(Intercept) 72.7393 3.9455 18.436 3.42e-07 ***\nhours 5.8093 1.1161 5.205 0.00125 ** \nprac_exams 0.3346 0.9369 0.357 0.73150    \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 3.59 on 7 degrees of freedom\nMultiple R-squared: 0.8004, Adjusted R-squared: 0.7434 \nF-statistic: 14.03 on 2 and 7 DF, p-value: 0.003553\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Agora, suponha que queiramos testar se o coeficiente <strong>de horas<\/strong> e <strong>prac_exams<\/strong> s\u00e3o ambos zero.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>LinearHypothesis()<\/strong> para fazer isso:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (car)\n\n<span style=\"color: #008080;\">#perform hypothesis test for hours=0 and prac_exams=0\n<\/span>linearHypothesis(fit, c(\" <span style=\"color: #ff0000;\">hours=0<\/span> \", \" <span style=\"color: #ff0000;\">prac_exams=0<\/span> \"))\n\nLinear hypothesis testing\n\nHypothesis:\nhours = 0\nprac_exams = 0\n\nModel 1: restricted model\nModel 2: score ~ hours + prac_exams\n\n  Res.Df RSS Df Sum of Sq F Pr(&gt;F)   \n1 9 452.10                                \n2 7 90.24 2 361.86 14.035 0.003553 **\n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">O teste de hip\u00f3tese retorna os seguintes valores:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>Estat\u00edstica do teste F<\/strong> : 14.035<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>valor p<\/strong> : 0,003553<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Este teste de hip\u00f3tese espec\u00edfico usa as seguintes hip\u00f3teses nulas e alternativas:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>H <sub>0<\/sub><\/strong> : Ambos os coeficientes de regress\u00e3o s\u00e3o iguais a zero.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong><sub>HA<\/sub><\/strong> : Pelo menos um coeficiente de regress\u00e3o n\u00e3o \u00e9 igual a zero.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Como o valor p do teste (0,003553) \u00e9 inferior a 0,05, rejeitamos a hip\u00f3tese nula.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Em outras palavras, n\u00e3o temos evid\u00eancias suficientes para afirmar que os coeficientes de regress\u00e3o para <strong>horas<\/strong> e <strong>prac_exames<\/strong> sejam ambos iguais a zero.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir fornecem informa\u00e7\u00f5es adicionais sobre regress\u00e3o linear em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/interpretar-a-saida-da-regressao-em-r\/\" target=\"_blank\" rel=\"noopener\">Como interpretar a sa\u00edda da regress\u00e3o em R<\/a><br \/> <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 \/> Como realizar regress\u00e3o log\u00edstica em R<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar a fun\u00e7\u00e3o LinearHypothesis() do pacote car em R para testar hip\u00f3teses lineares em um modelo de regress\u00e3o espec\u00edfico. Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica: linearHypothesis(fit, c(&#8221; var1=0 &#8220;, &#8221; var2=0 &#8220;)) Este exemplo espec\u00edfico testa se os coeficientes de regress\u00e3o var1 e var2 no modelo denominado ajuste s\u00e3o conjuntamente iguais a [&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-3904","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 a fun\u00e7\u00e3o LinearHypothesis() em R - Estatologia<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o LinearHypothesis() em R para testar hip\u00f3teses lineares em modelos de regress\u00e3o.\" \/>\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\/hipotese-linear-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como usar a fun\u00e7\u00e3o LinearHypothesis() em R - Estatologia\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o LinearHypothesis() em R para testar hip\u00f3teses lineares em modelos de regress\u00e3o.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/hipotese-linear-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-14T20:50:46+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\/hipotese-linear-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/hipotese-linear-r\/\",\"name\":\"Como usar a fun\u00e7\u00e3o LinearHypothesis() em R - Estatologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-14T20:50:46+00:00\",\"dateModified\":\"2023-07-14T20:50:46+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como usar a fun\u00e7\u00e3o LinearHypothesis() em R para testar hip\u00f3teses lineares em modelos de regress\u00e3o.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/hipotese-linear-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/hipotese-linear-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/hipotese-linear-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como usar a fun\u00e7\u00e3o linearhypothesis() em r\"}]},{\"@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 a fun\u00e7\u00e3o LinearHypothesis() em R - Estatologia","description":"Este tutorial explica como usar a fun\u00e7\u00e3o LinearHypothesis() em R para testar hip\u00f3teses lineares em modelos de regress\u00e3o.","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\/hipotese-linear-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como usar a fun\u00e7\u00e3o LinearHypothesis() em R - Estatologia","og_description":"Este tutorial explica como usar a fun\u00e7\u00e3o LinearHypothesis() em R para testar hip\u00f3teses lineares em modelos de regress\u00e3o.","og_url":"https:\/\/statorials.org\/pt\/hipotese-linear-r\/","og_site_name":"Statorials","article_published_time":"2023-07-14T20:50:46+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\/hipotese-linear-r\/","url":"https:\/\/statorials.org\/pt\/hipotese-linear-r\/","name":"Como usar a fun\u00e7\u00e3o LinearHypothesis() em R - Estatologia","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-14T20:50:46+00:00","dateModified":"2023-07-14T20:50:46+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como usar a fun\u00e7\u00e3o LinearHypothesis() em R para testar hip\u00f3teses lineares em modelos de regress\u00e3o.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/hipotese-linear-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/hipotese-linear-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/hipotese-linear-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como usar a fun\u00e7\u00e3o linearhypothesis() em r"}]},{"@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\/3904","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=3904"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/3904\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=3904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=3904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=3904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}