Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set.seed(1234)
- x <- rnorm(1000)
- y <- rbinom(1000, 1, exp(-2.3 + 0.1*x)/(1+exp(-2.3 + 0.1*x)))
- fit = glm(y ~ x, family=binomial(link='logit'))
- fit$coefficients
- p = sum(y)/length(y)
- z = rep(p, 1000)
- z_star = log(z/(1-z))
- fit2 = lm(z_star ~ x)
- fit2$coefficients
- > fit$coefficients
- (Intercept) x
- -2.2261215 0.1651474
- > fit2$coefficients
- (Intercept) x
- -2.219647e+00 -5.338566e-16
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement