inv_logit: An inverse logit function

Description Usage Arguments Examples

View source: R/inv_logit.R

Description

This function allows you to calculate probability from log odds

Usage

1
inv_logit(mod)

Arguments

mod

A glm object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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)
inv_logit(glm1)
inv_logit(glm2)
#inv_logit(testLM) # Gives an error

jvcasill/lingStuff documentation built on April 9, 2021, 10:42 a.m.