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 6.1 Synthetic data following a Poisson distribution in R

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

set.seed(2016)
nobs <- 500


x <- runif(nobs)
xb <- 1 + 2*x
py <- rpois(nobs, exp(xb))
summary(myp <- glm(py ~ x, family=poisson))

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

Output on screen:

​

Call:

glm(formula = py ~ x, family = poisson)

 

Deviance Residuals:

      Min             1Q      Median            3Q          Max

-3.2419      -0.7687      -0.0162      0.6284      3.1752

 

Coefficients:

                          Estimate       Std. Error        z value      Pr(>|z|)

(Intercept)          1.00106          0.04037           24.80      <2e-16 ***

x                         2.02577          0.05728           35.37      <2e-16 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 

(Dispersion parameter for poisson family taken to be 1)

 

       Null deviance: 1910.87 on 499 degrees of freedom

Residual deviance:   540.07 on 498 degrees of freedom

AIC: 2428.8

 

Number of Fisher Scoring iterations: 4

bottom of page