simondp

Untitled

Oct 19th, 2018
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.61 KB | None | 0 0
  1. # Generate data
  2. halfnorm <- rnorm(5000, mean=0,sd=20)
  3. halfnorm <- abs(halfnorm)
  4. unf <- runif(1000, min = 40, max = 180)
  5. dist <- c(halfnorm,unf)
  6.  
  7. # Inspect distributions
  8. hist(dist)
  9. hist(log(dist))
  10.  
  11. # Make dataframe (with 10 random IDs)
  12. id <- rep(1:10,(length(dist)/10))
  13. sim <- data.frame(dist,id)
  14.  
  15. # Import libraries for modelling
  16. library(loo)
  17. library(brms)
  18. options(mc.cores = 2)
  19.  
  20. # Default method
  21. m0 <- brm(dist ~ (1|id), data = sim, chains = 2,iter = 3000, warmup = 1000)
  22. pp_check(m0)
  23.  
  24. # Log method
  25. m0log <- brm(log(dist) ~ (1|id), data = sim, chains = 2,iter = 3000, warmup = 1000)
  26. pp_check(m0log)
Advertisement
Add Comment
Please, Sign In to add comment