[R-sig-ME] Unable to standardize glmmADMB global model

Ben Bolker bbolker at gmail.com
Tue Aug 16 13:55:36 CEST 2016


You can *scale* the offsets if you like, i.e. change them by a
multiplicative factor (thus changing the effective area unit for which
you were modeling counts), but *centering* them doesn't make sense --
as you've noticed.

On Tue, Aug 16, 2016 at 7:40 AM, Aoibheann Gaughran <gaughra at tcd.ie> wrote:
> Hi Ben,
>
> Im proceeding by standardizing by hand.  However, I need to include offsets
> in my model for origarea and PropAvlHab i.e. offset(log(z.origarea)) but
> logging the standardized varible produced NaNs due to the presence of
> negative numbers, ditto with z.PropAvlHab. Is there a way around this? Do I
> need to also standardize the offset terms or can I leave them in their
> unstandardized form?
>
> Many thanks,
>
> Aoibheann
>
> On 15 August 2016 at 15:47, Ben Bolker <bbolker at gmail.com> wrote:
>>
>> Hmm.  Surprising/hard to diagnose.
>>
>> 'standardize' doesn't do anything very fancy - it standardizes the
>> input variables as described by ?arm::standardize and *refits* the
>> model (I've always been a little disappointed that it doesn't
>> standardize by figuring out how to transform the *parameters*, which
>> is straightforward in principle although it can be tricky to figure
>> out how to deal with input variables that lead to multiple predictor
>> variables, e.g. polynomials).  I'd be curious to know what's going on,
>> but in your place I would
>>
>> (1) try standardizing by hand, e.g.
>>
>> std_data <- transform(data,
>>       z.season.wt = scale(season.wt),
>>      ...)
>>
>> and refit yourself.
>>
>> (2) see if it happens to work with glmmTMB (a simple example does).
>>
>>   Ben Bolker
>>
>>
>>
>>
>> On Mon, Aug 15, 2016 at 10:37 AM, Aoibheann Gaughran <gaughra at tcd.ie>
>> wrote:
>> > Thanks Ben, I ran the code and got the following error and warnings:-
>> >
>> > Error in glmmadmb(formula = field_count ~ habitat + season_wt + c.sex +
>> > :
>> >   rank of X = 16 < ncol(X) = 24
>> > In addition: Warning messages:
>> > 1: In log(z.PropAvlHab) : NaNs produced
>> > 2: In glmmadmb(formula = field_count ~ habitat + season_wt + c.sex +  :
>> >   NAs removed in constructing fixed-effect model frame: you should
>> > probably
>> > remove them manually, e.g. with na.omit()
>> >
>> >
>> > The original PropAvlHab summary is as follows:-
>> >
>> >> summary(dframe1$PropAvlHab)
>> >      Min.   1st Qu.    Median      Mean   3rd Qu.      Max.
>> > 0.0000123 0.1123000 0.4041000 0.4078000 0.6818000 1.0000000
>> >
>> > Aoibheann
>> >
>> >
>> >
>> > On 15 August 2016 at 15:12, Ben Bolker <bbolker at gmail.com> wrote:
>> >>
>> >> 'standardize' is a function from the arm package.
>> >>
>> >> I've just hacked glmmADMB a little bit so this should work:
>> >>
>> >> library(devtools)
>> >> install_github("bbolker/glmmADMB")  ## install latest version
>> >> library(arm)
>> >> arm:::standardize.default(fitted_model$call)
>> >>
>> >>
>> >>
>> >> On Mon, Aug 15, 2016 at 5:06 AM, Aoibheann Gaughran <gaughra at tcd.ie>
>> >> wrote:
>> >> > Hello Mixed-Modellers,
>> >> >
>> >> > I have getting the following error message when trying to standardize
>> >> > my
>> >> > global glmmadmb model for dredging:
>> >> >
>> >> > Error in (function (classes, fdef, mtable)  : unable to find an
>> >> > inherited
>> >> > method for function ‘standardize’ for signature ‘"glmmadmb"’
>> >> >
>> >> > Is it not possible to standardise a glmmadmb model or is the problem
>> >> > with
>> >> > the structure of the model itself?
>> >> >
>> >> > globalmod    <- glmmadmb(field_count ~ habitat
>> >> > #categorical - 7 levels
>> >> >                      + season_wt
>> >> >                                          #categorial - 3 levels
>> >> >                      + sex
>> >> >                                               #categorial - 2 levels
>> >> >                      + ageclass
>> >> >                                            #categorial - 3 levels
>> >> >                      + slope
>> >> >                                              #continuous, not scaled
>> >> > nor
>> >> > centred
>> >> >                      + NSEW
>> >> >                                           #catagorical - 4 levels
>> >> >                      + month_fix
>> >> >                                           #continuous, not scaled nor
>> >> > centred,
>> >> >                      + num_fields
>> >> >                   #continuous, not scaled nor centred
>> >> >                      + habitat:ageclass
>> >> >                      + habitat:sex
>> >> >                      + offset(log(origarea))
>> >> >                      + offset(log(PropAvlHab))
>> >> >                      +(1|individual_id)
>> >> >                                            #repeated obs from same
>> >> > individual
>> >> >                      +(1|field_id)
>> >> >                                               #repeated obs in same
>> >> > field,
>> >> >                      family="nbinom",
>> >> >                      zeroInflation=TRUE,
>> >> >                      admb.opts=admbControl(shess=FALSE,noinit=FALSE),
>> >> >                      debug=TRUE,
>> >> >                      data = dframe1)
>> >> >
>> >> > no of observations =9220
>> >> >
>> >> > Many thanks,
>> >> >
>> >> > --
>> >> > Aoibheann Gaughran
>> >> >
>> >> > Behavioural and Evolutionary Ecology Research Group
>> >> > Zoology Building
>> >> > School of Natural Sciences
>> >> > Trinity College Dublin
>> >> > Dublin 2
>> >> > Ireland
>> >> > Phone: +353 (86) 3812615
>> >> >
>> >> >         [[alternative HTML version deleted]]
>> >> >
>> >> > _______________________________________________
>> >> > R-sig-mixed-models at r-project.org mailing list
>> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>> >
>> >
>> >
>> >
>> > --
>> > Aoibheann Gaughran
>> >
>> > Behavioural and Evolutionary Ecology Research Group
>> > Zoology Building
>> > School of Natural Sciences
>> > Trinity College Dublin
>> > Dublin 2
>> > Ireland
>> > Phone: +353 (86) 3812615
>
>
>
>
> --
> Aoibheann Gaughran
>
> Behavioural and Evolutionary Ecology Research Group
> Zoology Building
> School of Natural Sciences
> Trinity College Dublin
> Dublin 2
> Ireland
> Phone: +353 (86) 3812615



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