library("gamlss2")
## load head circumference data
data("dbhh", package = "gamlss.data")
## specify the model Formula
<- head ~ pb(age) | pb(age) | pb(age) | pb(age)
f
## estimate model
<- gamlss2(f, data = dbhh, family = BCT) b
GAMLSS-RS iteration 1: Global Deviance = 26379.1782 eps = 0.390130
GAMLSS-RS iteration 2: Global Deviance = 26205.4924 eps = 0.006584
GAMLSS-RS iteration 3: Global Deviance = 26202.6475 eps = 0.000108
GAMLSS-RS iteration 4: Global Deviance = 26202.2604 eps = 0.000014
GAMLSS-RS iteration 5: Global Deviance = 26202.1179 eps = 0.000005
## visualize estimated effects
plot(b, which = "effects")
## plot diagnostics
plot(b, which = "resid")
## predict quantiles
<- quantile(b, probs = c(0.05, 0.5, 0.95))
pq
## plot
plot(head ~ age, data = dbhh, pch = 19,
col = rgb(0.1, 0.1, 0.1, alpha = 0.3))
matplot(dbhh$age, pq, type = "l",
lty = 1, col = 4, add = TRUE)