We use the logistic function to restrict the domain of to [0,1]$$$p(x) = \frac{e^x}{e^x + 1}$$ If we express p(x)x$ we produce

Refer to Odds

We have that the function is the logistic function and so it is restricted to produce values on .

However, since we’ve taken the inverse of the logistic function, the logit function can take on any value.

With this, we set . This makes sense because a line has the range .

Once again, we say that the is an example of a Link Function.

This function links the to a linear function.

We can fit the function to some data

p13.glm <- glm(y ~ x, data = p13.1, family = binomial)

This produces values for and .

We have We rewrite in terms of and have We now simulate from the model since we know and .

p <- exp(6.0709-0.0177*p13.1$x)/(1+exp(6.0709-0.0177*p13.1$x)
n <- nrow(p13.1)
simy <- rbinom(n, 1, prob = p)