Guest User

Untitled

a guest
Mar 22nd, 2018
323
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set.seed(1234)
  2. n = 4
  3. mu = 1
  4. a = rnorm(n, 0.0, 1)
  5. b1 = rnorm(n/2, mu - mu/4, 1)
  6. b2 = rnorm(n/2, mu + mu/4, 1) # interaction is mu/2
  7.  
  8. dat1 = dat2 = data.frame(Group = c(rep("C", n), rep("T", n)),
  9. Sex = rep(c(rep(0, n/2), rep(1, n/2)), 2),
  10. Val = c(a, b1, b2))
  11.  
  12. # Now male is the reference
  13. dat2$Sex = ifelse(dat2$Sex == 0, 1, 0)
  14.  
  15. fit1 = lm(Val ~ Group*Sex, dat1)
  16. fit2 = lm(Val ~ Group*Sex, dat2)
  17.  
  18. # Results
  19. dat1
  20. dat2
  21.  
  22. summary(fit1)
  23. summary(fit2)
RAW Paste Data