Skip to content

Commit

Permalink
fixed odds_ratios_significance location in notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
phelps-sg committed Jan 20, 2024
1 parent ab9494c commit 617f69d
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions jupyter-book/R-MixedModel.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# ---
# jupyter:
# jupytext:
# : jupytext:
# formats: ipynb,R:percent
# text_representation:
# extension: .R
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.0
# jupytext_version: 1.16.1
# kernelspec:
# display_name: R
# language: R
Expand Down Expand Up @@ -311,6 +309,28 @@ model_dictator_1 <- clmm(
# %%
summary(model_dictator_1)

# %%
as_odds <- function(model) {
m <- coef(summary(model))
if (testClass(m, "list")) {
m <- m$cond
}
m[, 1] <- exp(m[, 1])
m[, 2] <- exp(m[, 2])
colnames(m)[1] <- "Estimate (Odds ratio)"
return(m)
}

# %%
odds_ratios_significant <- function(model) {
m <- as_odds(model)
xtable(
m[m[, 4] < 0.05, ],
caption =
"Model estimates for significant coefficients only ($p<0.05$) on odds ratio scale"
)
}

# %%
print(odds_ratios_significant(model_dictator_1), type = "latex")

Expand Down Expand Up @@ -397,31 +417,9 @@ dev.off()
# %%
xtable(lme4::formatVC(summary(model_pd)$varcor$cond))

# %%
as_odds <- function(model) {
m <- coef(summary(model))
if (testClass(m, "list")) {
m <- m$cond
}
m[, 1] <- exp(m[, 1])
m[, 2] <- exp(m[, 2])
colnames(m)[1] <- "Estimate (Odds ratio)"
return(m)
}

# %%
as_odds(model_pd_1)

# %%
odds_ratios_significant <- function(model) {
m <- as_odds(model)
xtable(
m[m[, 4] < 0.05, ],
caption =
"Model estimates for significant coefficients only ($p<0.05$) on odds ratio scale"
)
}

# %%

odds_ratios_significant(model_pd_1)
Expand Down

0 comments on commit 617f69d

Please sign in to comment.