Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.39 KB | None | 0 0
  1. for(i in 1:1000){
  2. b0 <- 5
  3. b1 <- 0.2
  4. b2 <- 0.2
  5. x1 <- runif(50, 0, 10)
  6. x2 <- runif(50, 0, 10)
  7. e_var <- rnorm(50, 0, 3)
  8.  
  9. y <- b0 + x1 * b1 + x2 * b2 + e_var
  10.  
  11. mat[i, 1] <- summary(lm(y ~ x1 + x2))$coefficients[11] < 0.05
  12. mat[i, 2] <- summary(lm(y ~ x1 + x2))$coefficients[12] < 0.05
  13. }
  14.  
  15. mat$pw <-  mat[,1] * mat[,2]
  16. sum(mat[,1]) / 1000
  17. sum(mat[,2])  / 1000
  18. sum(mat[,3]) / 1000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement