This function allows you to calculate probability from log odds
inv_logit(mod)
# Generate data
set.seed(1)
vot <- rnorm(20, 15, 5)
vot <- sort(vot)
fac <- rnorm(20, 100, 100)
phon <- c(0,1,0,0,0,0,0,1,0,1,0,1,0,1,1,1,1,1,1,1)
df <- data.frame(vot = vot, fac = fac, phon = phon)
# Fit models
glm0 <- glm(phon ~ vot, data = df, family = "binomial")
glm1 <- glm(phon ~ vot + fac, data = df, family = "binomial")
glm2 <- glm(phon ~ vot * fac, data = df, family = "binomial")
testLM <- lm(speed ~ dist, data = cars)
# Get beta weights as probabilities
library(dplyr)
inv_logit(glm0)
#> variables betas prob
#> 1 (Intercept) -6.7418468 0.001179073
#> 2 vot 0.4339514 0.606816835
inv_logit(glm1)
#> variables betas prob
#> 1 (Intercept) -6.796121412 0.001116855
#> 2 fac -0.004534132 0.498866469
#> 3 vot 0.461287494 0.613319561
inv_logit(glm2)
#> variables betas prob
#> 1 (Intercept) -16.822413721 4.944456e-08
#> 2 fac 0.065710671 5.164218e-01
#> 3 vot 1.120974722 7.541695e-01
#> 4 vot:fac -0.004561813 4.988595e-01
#inv_logit(testLM) # Gives an error