[ADMB Users] R glmm.admb error trapping

H. Skaug hskaug at gmail.com
Thu Dec 23 00:06:50 PST 2010


Hi,

Try something like

problem = data.class(try(glmm.admb(---------------),silent=T))=="try-error"

if(!problem)
  glmm.admb(---------------)

This involves running the model twice, which takes more time.

I agree that more graceful exit from glmm.admb() would be preferable,
and we will
see what we can do.

Hans



On Tue, Dec 21, 2010 at 3:42 AM, Jager, Yetta <jagerhi at ornl.gov> wrote:
> Hello list,
>
> We are trying to compare a number of glmm.admb models with different fixed
> effects.  For convenience, we want to automate this and exclude unreasonable
> combinations afterward. We are losing control from an R function that calls
> glmm.admb after it fails with the message, ‘Hessian that does not appear to
> be positive definite’ (see below for partial output, B).
>
> Putting the call in a try loop (below A) did not work -- apparently control
> did not return to the function, but my understanding of how R try loops work
> is weak.  For the time being, we’re just looking for a graceful exit
> (control returned to function, ideally with a null model object returned),
> not necessarily a solution to the convergence problem, although we’ll take
> any help we can get.  For what its worth, this could be a model with high
> collinearity, but if we run it alone after it fails in the function call, we
> do get a solution, however unstable (below C).
>
> If there’s any other information i should have provided to help with solving
> this, please let me know and i’ll try again.  Thanks very much for any
> assistance.  I appreciate your time and experience.
>
> Yetta
>
>
> My code snippet from within a function:
>
> #   Run admb in try block
>     try
>     {
>         options(show.error.messages = TRUE);
> #     M[[my_id]] <- lm( new_fixed, data = Data);
>       M[[my_id]] <- glmm.admb( fixed = new_fixed, random = ~1, group =
> "Subregion", data = Data,
>       family = "nbinom", verbose = TRUE);
>     }
>     if (is.null(M[[my_id]]))
>     {
>         warnings();
>       print(paste("Model failed for variables ", new_fixed, sep=""));
>     }
>     else
>     {
>       print(M[[my_id]]);
>     }
>
> B) Excerpt of error from R Console:
> - final statistics:
> 10 variables; iteration 8; function evaluation 15
> Function value  7.3589e+002; maximum gradient component mag -7.5466e-005
> Exit code = 1;  converg criter  1.0000e-004
> Var   Value    Gradient   |Var   Value    Gradient   |Var   Value
> Gradient
>   1 46.2451 -2.6335e-005 |  2  3.7589 -4.2522e-005 |  3 -3.2869  1.5670e-005
>   4 -2.4314 -2.1427e-005 |  5 -0.1699  9.2829e-006 |  6  1.1824  9.5950e-006
>   7  2.5560  1.2540e-005 |  8  4.9276 -1.0343e-005 |  9 -0.9850 -7.5466e-005
> 10  0.0909 -7.3008e-006 |
> inner maxg = 7.625473665e-018  Inner f = 742.3228266
> f = 742.3228266 max g = 7.625473665e-018
> .
> .
> .
> Newton raphson 1   f = 742.3228521 max g = 8.934094073e-018
> inner maxg = 1.48457798e-008  Inner f = 742.3229286
> f = 742.3229286 max g = 1.48457798e-008
> Newton raphson 1   f = 742.3229286 max g = 1.422953313e-017
> Warning -- Hessian does not appear to be positive definite
> Error in glmm.admb(fixed = new_fixed, random = ~1, group = "Subregion",  :
>   The function maximizer failed
>
> C)
> .
> .
> .
> Newton raphson 1   f = 740.6118656 max g = 6.495461568e-017
> inner maxg = -1.83792469e-007  Inner f = 740.6119407
> f = 740.6119407 max g = 1.83792469e-007
> Newton raphson 1   f = 740.6119407 max g = 6.888384188e-017
> Warning message:
> In model.matrix.default(fixed, data) :
>   variable 'Subregion' converted to a factor
>> print(M[[my_id]])
>
> GLMM's in R powered by AD Model Builder:
>
>   Family: nbinom
>   alpha = 3.7056
>
> Fixed effects:
>   Log-likelihood: -734.179
>   Formula: N_Species ~ TPmgL + SedgL + HUC8_ups + Subregion
>               (Intercept)                     TPmgL
> SedgL
>                 3.0629000                -0.3526400
> -0.0072777
>                  HUC8_ups         SubregionCanadian
> SubregionCimarron
>                 0.0150080                -0.2057500
> -0.1883800
>            SubregionD_Red       SubregionL_Arkansas
> SubregionNeosho-Verdigris
>                 0.5095900                 0.8566100
> 1.1929000
>          SubregionU_White
>                 1.4180000
>
> Random effects:
>   Grouping factor: Subregion
>   Formula: ~1
> Structure: Diagonal matrix
> (Intercept)
> 0.0005155773
>
> Number of Observations: 173
> Number of Groups: 7
>
> Yetta Jager
> Environmental Sciences Division
> Oak Ridge National Laboratory
> P.O. Box 2008, MS 6036
> Oak Ridge, TN 37831-6036 USA
>
> For packages, please replace "P.O. Box 2008" with "Bethel Valley Road".
>
> OFFICE: 865/574-8143  FAX:  865/576-3989
> Work email: jagerhi at ornl.gov Home email: jagerhi at chartertn.net
> My webpage: http://www.esd.ornl.gov/~zij/
> Fish and Wildlife Modelling:
> http://www.esd.ornl.gov/research/ecol_management/fish_wildlife_modeling
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>
>



More information about the Users mailing list