set.seed(1001)
<- 1000
N <- c(1,2)
mean_pars <- c(1,2)
disp_pars <- data.frame(x=rnorm(N))
dd <- plogis(mean_pars[1]+mean_pars[2]*dd$x)
m <- exp(disp_pars[1]+disp_pars[2]*dd$x)
d $y <- rbeta(N,shape1=m*d,shape2=(1-m)*d) dd
Fit models:
## location only
<- glmmTMB(y~x,
m1 family=beta_family(),
data=dd)
## add model for dispersion
<- update(m1,dispformula=~x) m2
Fixed effects look close to theoretical values:
fixef(m2)
##
## Conditional model:
## (Intercept) x
## 1.005 2.013
##
## Dispersion model:
## (Intercept) x
## 1.064 1.962
AIC is insanely much better for the model with dispersion varying:
::AICtab(m1,m2) bbmle
## dAIC df
## m2 0.0 4
## m1 1491.6 3