Created
October 22, 2024 15:42
-
-
Save DATAUNIRIO/ed331960cd53aa6f2dbf32df75e048f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stats.oarc.ucla.edu/other/mult-pkg/faq/general/faq-how-do-i-interpret-odds-ratios-in-logistic-regression/ | |
dados = matrix(c(74, 17, 77, 32), ncol = 2) | |
dados | |
dimnames(dados) <- list(voto = c("Normal","Menção Honrosa"), | |
sexo = c("Masculino","Feminino")) | |
dados | |
mosaicplot(dados, color = c("skyblue", "pink"), xlab ="Menção Honrosa", | |
ylab = "Sexo") | |
prob_m = 17/(17+74+32+77) | |
prob_f = 32/(17+74+32+77) | |
odds_m = 17/74 | |
odds_f = 32/77 | |
odds_f/odds_m | |
fisher.test(dados) | |
#------------------------------------------------------------------------------------------------ | |
dados = matrix(c(69, 13, 33, 2), ncol = 2) | |
dimnames(dados) <- list(sexo = c("Feminino", "Masculino"), | |
voto = c("Kelmon","Não Kelmon")) | |
dados | |
mosaicplot(dados, color = c("darkred", "gold"), xlab ="Sexo", | |
ylab = "Voto no candidato padre") | |
aa = chisq.test(dados) | |
aa$expected | |
fisher.test(dados) | |
# sample odds-ratio estimate | |
69*2/(13*33) | |
a = 69/33 | |
b = 13/2 | |
a/b | |
b/a | |
#------------------------------------------------------------------------------------------------ | |
load(url("https://github.com/DATAUNIRIO/Base_de_dados/raw/refs/heads/master/Titanic.RData")) | |
tabela <- table(Titanic$Sexo, Titanic$Sobreviveu) | |
tabela | |
mosaicplot(tabela, color = c("darkred", "gold"), xlab ="Sexo", ylab = "Survivência") | |
TF <- fisher.test(tabela) | |
TF | |
TF | |
cf = 344/126 | |
cf | |
cm = 366/1364 | |
cm | |
cf/cm | |
cm/cf | |
# This shows that the odds ratio is about 10—the odds of a female surviving were about ten times the odds of a male surviving. | |
# This is (female survival / female death) / (male survival / male death). | |
# The order of the values in the odds ratios is determined by the order of the values of each variable;by default R uses alphabetical order. | |
# https://whitlockschluter3e.zoology.ubc.ca/RLabs/R_tutorial_Contingency_analysis.html#odds_ratios | |
#Titanic$vivo = ifelse(Titanic$Sobreviveu=="Sobreviveu",1,0) | |
#Titanic$aaa = ifelse(Titanic$Sexo=="Masculino",0,1) | |
#modelo = glm(vivo ~ aaa, data = Titanic) | |
#summary(modelo) | |
#exp(0.52035) | |
# razao de chances condicionais 68% maior de sobreviver | |
#-------------------------------------------------------------- | |
### Tabela para o teste | |
Tabela <- as.table(rbind(c(2,3,10,6,1), c(1,6,7,14,12))) | |
### Rótulos para tabela | |
dimnames(Tabela) <- list(sexo = c("Feminino", "Masculino"), | |
likert = c("Concordo Totalmente","Concordo", | |
"Nem concordo nem discordo", | |
"Discordo", "Discordo Totalmente")) | |
Tabela | |
Teste_fisher_hybrid <- fisher.test(Tabela, hybrid=TRUE) | |
Teste_fisher_hybrid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment