top of page

From: Bayesian Models for Astrophysical Data, Cambridge Univ. Press

(c) 2017,  Joseph M. Hilbe, Rafael S. de Souza and Emille E. O. Ishida  

 

you are kindly asked to include the complete citation if you used this material in a publication

​

​

Code 5.12   Synthetic beta-distributed data generated in R

====================================================

set.seed(1056)                                             # set seed to replicate example
nobs <- 1000                                               # number of obs in model


x1 <- runif(nobs)                                         # random normal variable
xb <- 0.3+1.5*x1                                        # linear predictor
exb <- exp(-xb)                                           # prob of 0
p <- exb/(1+exb)                                         # prob of 1


theta <- 15
 

y <- rbeta(nobs,theta*(1-p),theta*p)

 

summary(y)

 

hist(y)

====================================================

Output on screen:

​

    Min.    1st Qu.      Median       Mean      3rd Qu.        Max.

0.2616     0.6392       0.7487      0.7339      0.8447      0.9849

bottom of page