Problem in the Maximum Likelihood Estimation of Size

39 views
Skip to first unread message

MatM

unread,
Nov 2, 2015, 4:44:56 AM11/2/15
to Aster Analysis User Group
Dear all,

I am trying to make an analysis were a binary variable (reproduction) is followed by a zero-truncated negative binomial (nb if inflorescences). There are many examples in the aster documentation of a similar graph. I am encountering a problem when re-fiting a model for the profile of likelihood for the size estimation, using the parameters of a previous fit as initial parameters for the optimization. The aster funct
ion returns this error:

Error in aster.default(x, root, pred, fam, modmat, parm, type, famlist, :   parm wrong length, not dimension 3 of modmat.

I managed to replicate the error using modified code from the TR658 (see attachment). If I use the code as it is, everything works perfectly (as expected). But when I modify the call to the aster function, trying to use the layers and "no naked predictor" way I understand is advised now, I get exactly the same type of error as with my data. I thus attached this script, as the data are well known and already in the package.

I do not know what I am doing wrong in the model specification, and I cannot figure out why this error message happens, as I checked the dimension 3 of modmat and the length of the parameter vectors and they are the same.

If I remove the "parms" part, there is no error, and I wonder if this step is necessary. If I don't use starting values, the model should take a bit longer to converge, but except for that, it should do the same, or am I wrong about this?

What do you think?

Thanks in advance

Mathilde
code_tr658.R

geyer

unread,
Nov 5, 2015, 11:28:39 AM11/5/15
to Aster Analysis User Group
The code you attached works (does not exhibit the error) so I am not sure exactly what you are complaining about.

Your last statement is correct.  Leaving off initial values should not change the results.

The error you show is clear (at least to me) about what it is complaining about.  From the help page for the aster function

    parm: usually missing.  Otherwise a vector of length ‘ncoef’ giving
          a starting point for the optimization.

and then just above it says modmat is a three-way array and ncoef is its third dimension.  But what modmat?  You did not specify a modmat!  Just a formula!
If aout is the result of the aster fit, then aout$modmat is that model matrix.

This problem arises when some of what the R formula mini-language constructs as predictors are actually aliased (and the R formula mini-language is too stupid to know it) so the R function aster drops those predictors, but this check doesn't know (yet) which predictors are going to be dropped.  I admit this is a bad feature of the R function aster (both BAD and PBD) but it is used so infrequently, I haven't fixed it.

If you really need this.  Provide an example that is what you want to do (and crashes) and I will try to show you how to get starting values that work.
Reply all
Reply to author
Forward
0 new messages