SlideShare uma empresa Scribd logo
+
Bioestatística - Universidade Católica de Brasília
ANOVA e modelos
Prof. Dr. Gabriel da Rocha Fernandes
Universidade Católica de Brasília
gabrielf@ucb.br - fernandes.gabriel@gmail.com
+
Ideias
2
nSeus resultados são quantitativos.
nVocê tem multiplas variáveis que possam explicar seus
resultados.
nObjetivo é identificar a contribuição de diferentes variáveis
para seu resultado final.
nExemplo:
n “For the button, an A/B test of three new word choices—”Learn More,”
“Join Us Now,” and “Sign Up Now”—revealed that “Learn More”
garnered 18.6 percent more signups per visitor than the default of “Sign
Up.” Similarly, a black-and-white photo of the Obama family
outperformed the default turquoise image by 13.1 percent. Using both
the family image and “Learn More,” signups increased by a thundering
40 percent.”
+
Exemplo
nCarregar os dados:
n movies <- read.table("movies.txt",sep="t",header=T,quote="")
n head(movies)
n factor(movies$rating)
nRelacionando o score com rating:
n recebe o valor lógico 1 se o filme for PG e 0 se não
for.
3
+
ANOVA no R
nFunção aov:
n aovObject <- aov(movies$score ~ movies$rating)
n aovObject
n aovObject$coefficients
nSegunda variável:
n aovObject2 <- aov(movies$score ~ movies$rating + movies$genre)
n aovObject2
4
+
Interpretando
nsummary(aovObject2)
nInvertendo a ordem:
n aovObject3 <- aov(movies$score ~ movies$genre + movies$rating)
n summary(aovObject3)
nPrimeiro F-value explica a variação gerada pela primeira
variável sem tomar em conta nenhuma outra variável.
nSegundo F-value explica a variação gerada pela segunda
variável que não foi explicada pela primeira.
nPode adicionar variáveis quantitativas.
5
+
Resultados binários
nMorreu/Sobreviveu
nGanhou/Perdeu
nSucesso/Falha
nBinário é o famoso “é/não é”
nRegressão linear não funciona
nCarregando os dados:
n load("/var/www/fileserver/ravensData.rda")
n head(ravensData)
6
+
Modelo linear disso
nlmRavens <- lm(ravensData$ravenWinNum ~ ravensData
$ravenScore)
nsummary(lmRavens)
nTem chance de 28% de ganhar se não marcar nenhum ponto?
nA cada ponto marcado aumenta 1,5% a chance de ganhar?
nPlotando:
n plot(ravensData$ravenScore,lmRavens
$fitted,pch=19,col="blue",ylab="Prob Win",xlab="Raven Score")
nProbabilidade maior que 1?
7
+
Chances
nBinário
n 0/1
nProbabilidade (0,1)
n
nChances (0, inf)
n
nLog chance (-inf, inf)
8
+
Entendendo as chances
9
+
Regressão logística
nFunção:
n logRegRavens <- glm(ravensData$ravenWinNum ~ ravensData
$ravenScore,family="binomial")
n summary(logRegRavens)
nexp(b1) é o tanto que aumenta a chance do Ravens ganhar ao
marcar um ponto.
nPlotando:
n plot(ravensData$ravenScore,logRegRavens
$fitted,pch=19,col="blue",xlab="Score",ylab="Prob Ravens Win")
10
+
Chances e intervalos de confiança
nChances menores que 1 quer dizer que é mais provável que
percam.
nChances maiores que 1 quer dizer que é mais provável que
ganhem.
nCalculando as chances e intervalo de confiaça:
n exp(logRegRavens$coefficients)
n exp(confint(logRegRavens))
nInterpretando:
n Chance 1 quer dizer que não há diferença entre ganhar e perder (50%/
50%)
n Se o intervalo de confiança engloba o valor “1” quer dizer que não
relação entre os pontos marcados e a chance de ganhar. Existem outros
fatores.
11
+
ANOVA para regressão logística
nUsando Chi-quadrado:
n anova(logRegRavens,test="Chisq")
nChi-quadrado lida com probabilidades.
12
+
Selecionando o modelo
nCarregue os dados:
n movies <- read.table("movies.txt",sep="t",header=T,quote="")
n movies <- movies[,-1]
nSelecionando:
n lm1 <- lm(score ~ .,data=movies)
n aicFormula <- step(lm1)
n aicFormula
nAIC fornece uma estimativa relativa da quantidade de
informação que você perde quando aplica aquele modelo.
13

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Estatística - Aula 4

  • 1. + Bioestatística - Universidade Católica de Brasília ANOVA e modelos Prof. Dr. Gabriel da Rocha Fernandes Universidade Católica de Brasília gabrielf@ucb.br - fernandes.gabriel@gmail.com
  • 2. + Ideias 2 nSeus resultados são quantitativos. nVocê tem multiplas variáveis que possam explicar seus resultados. nObjetivo é identificar a contribuição de diferentes variáveis para seu resultado final. nExemplo: n “For the button, an A/B test of three new word choices—”Learn More,” “Join Us Now,” and “Sign Up Now”—revealed that “Learn More” garnered 18.6 percent more signups per visitor than the default of “Sign Up.” Similarly, a black-and-white photo of the Obama family outperformed the default turquoise image by 13.1 percent. Using both the family image and “Learn More,” signups increased by a thundering 40 percent.”
  • 3. + Exemplo nCarregar os dados: n movies <- read.table("movies.txt",sep="t",header=T,quote="") n head(movies) n factor(movies$rating) nRelacionando o score com rating: n recebe o valor lógico 1 se o filme for PG e 0 se não for. 3
  • 4. + ANOVA no R nFunção aov: n aovObject <- aov(movies$score ~ movies$rating) n aovObject n aovObject$coefficients nSegunda variável: n aovObject2 <- aov(movies$score ~ movies$rating + movies$genre) n aovObject2 4
  • 5. + Interpretando nsummary(aovObject2) nInvertendo a ordem: n aovObject3 <- aov(movies$score ~ movies$genre + movies$rating) n summary(aovObject3) nPrimeiro F-value explica a variação gerada pela primeira variável sem tomar em conta nenhuma outra variável. nSegundo F-value explica a variação gerada pela segunda variável que não foi explicada pela primeira. nPode adicionar variáveis quantitativas. 5
  • 6. + Resultados binários nMorreu/Sobreviveu nGanhou/Perdeu nSucesso/Falha nBinário é o famoso “é/não é” nRegressão linear não funciona nCarregando os dados: n load("/var/www/fileserver/ravensData.rda") n head(ravensData) 6
  • 7. + Modelo linear disso nlmRavens <- lm(ravensData$ravenWinNum ~ ravensData $ravenScore) nsummary(lmRavens) nTem chance de 28% de ganhar se não marcar nenhum ponto? nA cada ponto marcado aumenta 1,5% a chance de ganhar? nPlotando: n plot(ravensData$ravenScore,lmRavens $fitted,pch=19,col="blue",ylab="Prob Win",xlab="Raven Score") nProbabilidade maior que 1? 7
  • 10. + Regressão logística nFunção: n logRegRavens <- glm(ravensData$ravenWinNum ~ ravensData $ravenScore,family="binomial") n summary(logRegRavens) nexp(b1) é o tanto que aumenta a chance do Ravens ganhar ao marcar um ponto. nPlotando: n plot(ravensData$ravenScore,logRegRavens $fitted,pch=19,col="blue",xlab="Score",ylab="Prob Ravens Win") 10
  • 11. + Chances e intervalos de confiança nChances menores que 1 quer dizer que é mais provável que percam. nChances maiores que 1 quer dizer que é mais provável que ganhem. nCalculando as chances e intervalo de confiaça: n exp(logRegRavens$coefficients) n exp(confint(logRegRavens)) nInterpretando: n Chance 1 quer dizer que não há diferença entre ganhar e perder (50%/ 50%) n Se o intervalo de confiança engloba o valor “1” quer dizer que não relação entre os pontos marcados e a chance de ganhar. Existem outros fatores. 11
  • 12. + ANOVA para regressão logística nUsando Chi-quadrado: n anova(logRegRavens,test="Chisq") nChi-quadrado lida com probabilidades. 12
  • 13. + Selecionando o modelo nCarregue os dados: n movies <- read.table("movies.txt",sep="t",header=T,quote="") n movies <- movies[,-1] nSelecionando: n lm1 <- lm(score ~ .,data=movies) n aicFormula <- step(lm1) n aicFormula nAIC fornece uma estimativa relativa da quantidade de informação que você perde quando aplica aquele modelo. 13