Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. set.seed(1234)
  2. x <- rnorm(1000)
  3. y <- rbinom(1000, 1, exp(-2.3 + 0.1*x)/(1+exp(-2.3 + 0.1*x)))
  4.  
  5. fit = glm(y ~ x, family=binomial(link='logit'))
  6. fit$coefficients
  7.  
  8. p = sum(y)/length(y)
  9. z = rep(p, 1000)
  10. z_star = log(z/(1-z))
  11. fit2 = lm(z_star ~ x)
  12. fit2$coefficients
  13.  
  14. > fit$coefficients
  15. (Intercept) x
  16. -2.2261215 0.1651474
  17.  
  18. > fit2$coefficients
  19. (Intercept) x
  20. -2.219647e+00 -5.338566e-16
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement