Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

264 reglog 2020 #266

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Aulas/BE-Regressao-Logistica-cap31-32.tex
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,30 @@ \subsection{Regressão Linear Múltipla}
\end{exampleblock}
\end{frame}

\begin{frame}{\scriptsize Conclusão}
\begin{center}
Qual das quatro estimativas de BMI é a melhor?

\bigskip
Por que?
\end{center}
\end{frame}

\begin{frame}{\scriptsize Qual das estimativas é melhor? Por que?}
\begin{exampleblock}{\scriptsize Modelo 1 -- BMI (estimativa ``crua'')}
-1.99, IC: [-2.40, -1.59]
\end{exampleblock}
\begin{exampleblock}{\scriptsize Modelo 2.1 -- BMI ajustado por idade}
-2.04, IC: [-2.37, -1.70]
\end{exampleblock}
\begin{exampleblock}{\scriptsize Modelo 2.2 -- BMI ajustado por vitamina D sérica}
-1.91, IC: [-2.14, -1.68]
\end{exampleblock}
\begin{exampleblock}{\scriptsize Modelo 3 -- BMI ajustado por idade + vitamina D sérica}
-1.95, IC: [-2.05, -1.85]
\end{exampleblock}
\end{frame}

\section{Regressão Logística}

\subsection{Regressão Logística}
Expand Down
15 changes: 9 additions & 6 deletions Aulas/Cap31-32/glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@ library(philsfmisc)

# dados simulados ---------------------------------------------------------

source('~/Documents/Docencia/Bioestatistica/Aulas/Cap31-32/rlm.R')
dados.rlm <- fread("Aulas/Cap31-32/dados-rlm.csv", stringsAsFactors = TRUE)
dados.rlm$vitD <- factor(dados.rlm$vitD, levels = c("baixa", "media", "alta"))
dados.rlm$osteo <- relevel(dados.rlm$osteo, "Sadio")
summary(dados.rlm)

# modelos -----------------------------------------------------------------

glm.modelo4 <- glm(osteo ~ idoso, binomial, dados.rlm)
summary(glm.modelo4)

c(format.float(exp(coef(glm.modelo4)[2])), format.interval(exp(confint.default(glm.modelo4)[2, ])))
paste0("OR: ", format.float(exp(coef(glm.modelo4)[2])), ", IC: ", format.interval(exp(confint.default(glm.modelo4)[2, ])))

tc.idoso.osteo <- with(dados.rlm, table(idoso, osteo))
fisher.test(tc.idoso.osteo)
paste0("OR: ", format.float(fisher.test(tc.idoso.osteo)$estimate), ", IC: ", format.interval(fisher.test(tc.idoso.osteo)$conf.int))

glm.modelo5 <- glm(osteo ~ BMI + idade + vitD, binomial, dados.rlm)
summary(glm.modelo5)

c(format.float(exp(coef(glm.modelo5)[2])), format.interval(exp(confint.default(glm.modelo5)[2, ])))
c(format.float(exp(coef(glm.modelo5)[3])), format.interval(exp(confint.default(glm.modelo5)[3, ])))
c(format.float(exp(coef(glm.modelo5)[4])), format.interval(exp(confint.default(glm.modelo5)[4, ])))
c(format.float(exp(coef(glm.modelo5)[5])), format.interval(exp(confint.default(glm.modelo5)[5, ])))
paste0("OR: ", format.float(exp(coef(glm.modelo5)[2])), ", IC: ", format.interval(exp(confint.default(glm.modelo5)[2, ])))
paste0("OR: ", format.float(exp(coef(glm.modelo5)[3])), ", IC: ", format.interval(exp(confint.default(glm.modelo5)[3, ])))
paste0("OR: ", format.float(exp(coef(glm.modelo5)[4]), 7), ", IC: ", format.interval(exp(confint.default(glm.modelo5)[4, ]), 7))
paste0("OR: ", format.float(exp(coef(glm.modelo5)[5]), 7), ", IC: ", format.interval(exp(confint.default(glm.modelo5)[5, ]), 7))

# graficos ----------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions Aulas/Cap31-32/rlm.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ rlm.modelo2.2 <- lm(BMD ~ BMI + vitD, data = dados.rlm)
rlm.modelo3 <- lm(BMD ~ BMI + idade + vitD, data = dados.rlm)

print(summary(rlm.modelo1))
paste0(format.float(coef(rlm.modelo1)[2]), ", IC: ", format.interval(confint.default(rlm.modelo1)[2, ]))
print(summary(rlm.modelo2))
print(summary(rlm.modelo2.1))
paste0(format.float(coef(rlm.modelo2.1)[2]), ", IC: ", format.interval(confint.default(rlm.modelo2.1)[2, ]))
print(summary(rlm.modelo2.2))
paste0(format.float(coef(rlm.modelo2.2)[2]), ", IC: ", format.interval(confint.default(rlm.modelo2.2)[2, ]))
print(summary(rlm.modelo3))
paste0(format.float(coef(rlm.modelo3)[2]), ", IC: ", format.interval(confint.default(rlm.modelo3)[2, ]))

# graficos ----------------------------------------------------------------

Expand Down