[R-sig-ME] random slope and intercept in gamlss

Mollie Brooks mollieebrooks at gmail.com
Thu Oct 19 19:07:44 CEST 2017


Hi mixed modellers,

I've been struggling to figure out how to fit a model in gamlss with
correlated random effects of slope and intercept. I can fit one model that
might be right, but I can't find the random effect estimates to check.

Can anyone tell me if m1 or m2 below is the right code for a correlated
random slope and intercept as simulated below?

Thanks,
Mollie

library(MASS)
library(gamlss)

ni=50 #num groups in RE
nrep=10 #num reps per group
sdi=1
sdii=.1
rho = .5
slope=.8

dat=expand.grid(i=1:ni, rep=1:nrep, x=c(0, .1, .2, .4))
RE =mvrnorm(n=ni, mu =c(0,0), Sigma = matrix(c(sdi*sdi, rho*sdi*sdii,
rho*sdi*sdii, sdii*sdii),2,2))
dat=transform(dat, obs=rpois(n=nrow(dat), lambda =
exp(RE[i,1]+x*(slope+RE[i,2]))))

m0= gamlss(obs~x+re(random=~1|i), family=PO, data = dat)
m1= gamlss(obs~x+re(random=~1+x|i, correlation=corSymm()), family=PO, data
= dat, start.from=m0)
m2= gamlss(obs~x+re(random=~1+x|i), family=PO, data = dat, start.from=m0)

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list