SHARE
TWEET

Untitled

a guest Jun 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top