Guest User

Untitled

a guest
Mar 13th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. n <- 54
  2. set.seed(123)
  3. x <- rbinom(n, 1, .4)
  4. y <- rbinom(n, 1, .6)
  5.  
  6. tbl <- table(x=x,y=y)
  7.  
  8. mod <- glm(y ~ x, family=binomial())
  9.  
  10. # all the same at 0.5757576
  11. binomial()$linkinv( mod$coef[1])
  12. mean(y[x == 0])
  13. tbl[1,2] / sum(tbl[1,])
  14.  
  15. # all the same at 0.5714286
  16. binomial()$linkinv( mod$coef[1] + mod$coef[2])
  17. mean(y[x == 1])
  18. tbl[2,2] / sum(tbl[2,])
Add Comment
Please, Sign In to add comment