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.3 Synthetic lognormal data generated in R
==================================================

require(gamlss) 

​

# Data
set.seed(1056)                                                                # set seed to replicate example
nobs = 5000                                                                   # number of observations in model
x1 <- runif(nobs)                                                           # random uniform variable
xb <- 2 + 3*x1                                                               # linear predictor, xb
y <- rlnorm(nobs, xb, sdlog=1)                                     # create y as random lognormal variate

 

summary(mylnm <- gamlss(y ~ x1, family=LOGNO)) 

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

​

Output on screen:

​

GAMLSS-RS iteration 1: Global Deviance = 49159.59

GAMLSS-RS iteration 2: Global Deviance = 49159.59

******************************************************************

Family:     c("LOGNO", "Log Normal")

 

Call: gamlss(formula = y ~ x1, family = LOGNO)

 

Fitting method: RS()

 

--------------------------------------------------------------------------------------------------

Mu link function: identity

Mu Coefficients:

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

(Intercept)          1.99350             0.02816           70.78            <2e-16 ***

x1                       3.00663             0.04868           61.76            <2e-16 ***

---

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

​

----------------------------------------------------------------------------------------------------

Sigma link function: log

Sigma Coefficients:

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

(Intercept)       -0.001669           0.010000          -0.167             0.867

​

---------------------------------------------------------------------------------------------------- 

No. of observations  in  the fit: 5000

Degrees of Freedom for the fit: 3

       Residual Deg. of Freedom: 4997

                                     at cycle: 2

 

Global Deviance: 49159.59

                    AIC: 49165.59

                   SBC: 49185.14

******************************************************************

bottom of page