NaNs produced when using aodml beta-binomial model in aods3 package

Viewed 111

When trying to use the aodml funciton to fit a beta-binomial distribution GLM with my own data I get a warning message, stating that there are NaNs produced. When I tried to run the same function with the dataset given in the example of the aods3 package I get the same warning messages.

Code:

library(aods3)
data(orob2)
fm1<-aodml(cbind(m, n-m)~seed, data=orob2, family="bb")

Warning messages:
1: In lbeta(a, b): NaNs produced

I have an inkling that the warning is caused by the cbind(m, n-m) but I don't know why or how? Any ideas, especially strange since this is happening with the example data? Am I missing something here?

1 Answers

The problem here is that the optimization procedure tries a negative value of the dispersion parameter along the way. You can see this yourself by setting

options(warn=2, error=recover)

which specifies that warnings get converted to errors, and that errors trigger debug mode. Once you do this, re-run the aodml(...) command, choose frame 4, and print the values of m, n, mu, and k being passed to dbetabin. You'll see that k is negative.

You can resolve this by setting phi.scale="log", which will fit the dispersion parameter on a log scale (which makes more sense anyway).

Related