Discussion:
[R-sig-ME] warnings when using binomial models and offset
Joana Martelo
2018-11-23 17:26:04 UTC
Permalink
Hello everyone



I'm trying to model fish capture success using length, velocity and group
composition as explanatory variables, density as an offset variable, and
fish.id. as random effect. I'm getting the follow warnings:



Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binomial,dat
a=cap)



Warning messages:

1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :

Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)

2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :

Model is nearly unidentifiable: very large eigenvalue

- Rescale variables?





- I only get the warnings when I use length and group composition,
not with velocity.

- I don't get any warning if I don't use the offset.



I've tried:

Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family=binom
ial(link="cloglog"),data=cap)



But still get the warning.



Any ideas of what might be the problem?



Many thanks!





Joana Martelo









Melhores cumprimentos,



Joana Martins








[[alternative HTML version deleted]]
Ben Bolker
2018-11-23 21:53:43 UTC
Permalink
This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if
you use density, then you end up specifying that your capture counts are
proportional to exp(density), which is often a ridiculously huge number.

cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and group
composition as explanatory variables, density as an offset variable, and
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binomial,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Joana Martelo
2018-11-26 12:33:05 UTC
Permalink
Thanks for your email!

Warnings' problem is solved, however, when I use log(density) or log(density+1) I got NaNs because density has negative numbers. Density is 2,4,6 which standardized gives -1.793073717, -0.450015136, 0.893043446. So, log(-1.793073717+1)= NaN

Any suggestions?

Many thanks!
Joana


-----Mensagem original-----
De: R-sig-mixed-models [mailto:r-sig-mixed-models-***@r-project.org] Em nome de Ben Bolker
Enviada: sexta-feira, 23 de Novembro de 2018 21:54
Para: r-sig-mixed-***@r-project.org
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset


This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if you use density, then you end up specifying that your capture counts are proportional to exp(density), which is often a ridiculously huge number.

cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and
group composition as explanatory variables, density as an offset
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binomi
al,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family
=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
R-sig-mixed-***@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

---
Este e-mail foi verificado em termos de vírus pelo AVG.
http://www.avg.com
Mollie Brooks
2018-11-26 12:35:48 UTC
Permalink
If you’re using the scale() function to standardize your density values, you could use the argument, center=FALSE, to avoid subtracting the mean and thus avoid negative densities.

cheers,
Mollie
Post by Joana Martelo
Thanks for your email!
Warnings' problem is solved, however, when I use log(density) or log(density+1) I got NaNs because density has negative numbers. Density is 2,4,6 which standardized gives -1.793073717, -0.450015136, 0.893043446. So, log(-1.793073717+1)= NaN
Any suggestions?
Many thanks!
Joana
-----Mensagem original-----
Enviada: sexta-feira, 23 de Novembro de 2018 21:54
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset
This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if you use density, then you end up specifying that your capture counts are proportional to exp(density), which is often a ridiculously huge number.
cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and
group composition as explanatory variables, density as an offset
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binomi
al,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family
=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
---
Este e-mail foi verificado em termos de vírus pelo AVG.
http://www.avg.com
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Joana Martelo
2018-11-26 13:47:06 UTC
Permalink
Thanks for your help!

However, I still get the warnings when using offset(log(density)
Model1<-glmer(capture~length+offset(log(density+2))+(1|fish.id.c),family=binomial,data=cap)
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge with max|grad| = 0.258231 (tol = 0.001, component 1)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?


Any suggestion?

Thanks
Joana



-----Mensagem original-----
De: Mollie Brooks [mailto:***@gmail.com]
Enviada: segunda-feira, 26 de Novembro de 2018 12:36
Para: Joana Martelo
Cc: R SIG Mixed Models
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset - NaNs

If you’re using the scale() function to standardize your density values, you could use the argument, center=FALSE, to avoid subtracting the mean and thus avoid negative densities.

cheers,
Mollie
Thanks for your email!
Warnings' problem is solved, however, when I use log(density) or
log(density+1) I got NaNs because density has negative numbers.
Density is 2,4,6 which standardized gives -1.793073717, -0.450015136,
0.893043446. So, log(-1.793073717+1)= NaN
Any suggestions?
Many thanks!
Joana
-----Mensagem original-----
De: R-sig-mixed-models
Bolker
Enviada: sexta-feira, 23 de Novembro de 2018 21:54
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset
This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if you use density, then you end up specifying that your capture counts are proportional to exp(density), which is often a ridiculously huge number.
cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and
group composition as explanatory variables, density as an offset
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binom
i
al,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),famil
y
=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
---
Este e-mail foi verificado em termos de vírus pelo AVG.
http://www.avg.com
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Ben Bolker
2018-11-26 14:05:06 UTC
Permalink
Have you looked at the ?convergence help page?

By the way, what is the purpose of the +2 in your offset term? Are
you still centering your offset?
Post by Joana Martelo
Thanks for your help!
However, I still get the warnings when using offset(log(density)
Model1<-glmer(capture~length+offset(log(density+2))+(1|fish.id.c),family=binomial,data=cap)
Model failed to converge with max|grad| = 0.258231 (tol = 0.001, component 1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
Any suggestion?
Thanks
Joana
-----Mensagem original-----
Enviada: segunda-feira, 26 de Novembro de 2018 12:36
Para: Joana Martelo
Cc: R SIG Mixed Models
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset - NaNs
If you’re using the scale() function to standardize your density values, you could use the argument, center=FALSE, to avoid subtracting the mean and thus avoid negative densities.
cheers,
Mollie
Thanks for your email!
Warnings' problem is solved, however, when I use log(density) or
log(density+1) I got NaNs because density has negative numbers.
Density is 2,4,6 which standardized gives -1.793073717, -0.450015136,
0.893043446. So, log(-1.793073717+1)= NaN
Any suggestions?
Many thanks!
Joana
-----Mensagem original-----
De: R-sig-mixed-models
Bolker
Enviada: sexta-feira, 23 de Novembro de 2018 21:54
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset
This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if you use density, then you end up specifying that your capture counts are proportional to exp(density), which is often a ridiculously huge number.
cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and
group composition as explanatory variables, density as an offset
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binom
i
al,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),famil
y
=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
---
Este e-mail foi verificado em termos de vírus pelo AVG.
http://www.avg.com
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Joana Martelo
2018-11-26 14:18:43 UTC
Permalink
Yes, I was centering my offset, but that was before I see your email. It was just another option.
I'll have a look at the ?convergence help page?.
Thanks
Joana

-----Mensagem original-----
De: R-sig-mixed-models [mailto:r-sig-mixed-models-***@r-project.org] Em nome de Ben Bolker
Enviada: segunda-feira, 26 de Novembro de 2018 14:05
Para: r-sig-mixed-***@r-project.org
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset (log(x))


Have you looked at the ?convergence help page?

By the way, what is the purpose of the +2 in your offset term? Are you still centering your offset?
Post by Joana Martelo
Thanks for your help!
However, I still get the warnings when using offset(log(density)
Model1<-glmer(capture~length+offset(log(density+2))+(1|fish.id.c),fam
ily=binomial,data=cap)
Model failed to converge with max|grad| = 0.258231 (tol = 0.001, component 1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
Any suggestion?
Thanks
Joana
-----Mensagem original-----
Enviada: segunda-feira, 26 de Novembro de 2018 12:36
Para: Joana Martelo
Cc: R SIG Mixed Models
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset - NaNs
If you’re using the scale() function to standardize your density values, you could use the argument, center=FALSE, to avoid subtracting the mean and thus avoid negative densities.
cheers,
Mollie
Thanks for your email!
Warnings' problem is solved, however, when I use log(density) or
log(density+1) I got NaNs because density has negative numbers.
Density is 2,4,6 which standardized gives -1.793073717, -0.450015136,
0.893043446. So, log(-1.793073717+1)= NaN
Any suggestions?
Many thanks!
Joana
-----Mensagem original-----
De: R-sig-mixed-models
Bolker
Enviada: sexta-feira, 23 de Novembro de 2018 21:54
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset
This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if you use density, then you end up specifying that your capture counts are proportional to exp(density), which is often a ridiculously huge number.
cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and
group composition as explanatory variables, density as an offset
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=bino
m
i
al,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),fami
l
y
=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
---
Este e-mail foi verificado em termos de vírus pelo AVG.
http://www.avg.com
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
R-sig-mixed-***@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Ben Bolker
2018-11-26 14:01:11 UTC
Permalink
More generally: I would ask whether it makes sense to scale the
density at all; if your density is measured in sensible areal units
(e.g. individuals/hectare), then leaving it as-is will mean that your
other parameters will be in units of their effects on
capture/(individuals/hectare). Maybe you've been standardizing all of
your predictors according to the (generally wise) advice that
standardizing makes parameters more comparable/interpretable -- but
offsets are an exception to this advice ...
Post by Mollie Brooks
If you’re using the scale() function to standardize your density values, you could use the argument, center=FALSE, to avoid subtracting the mean and thus avoid negative densities.
cheers,
Mollie
Post by Joana Martelo
Thanks for your email!
Warnings' problem is solved, however, when I use log(density) or log(density+1) I got NaNs because density has negative numbers. Density is 2,4,6 which standardized gives -1.793073717, -0.450015136, 0.893043446. So, log(-1.793073717+1)= NaN
Any suggestions?
Many thanks!
Joana
-----Mensagem original-----
Enviada: sexta-feira, 23 de Novembro de 2018 21:54
Assunto: Re: [R-sig-ME] warnings when using binomial models and offset
This is a pretty common error, which I've now added to the GLMM FAQ.
You should be using log(density), not density, as your offset term; if you use density, then you end up specifying that your capture counts are proportional to exp(density), which is often a ridiculously huge number.
cheers
Ben Bolker
Post by Joana Martelo
Hello everyone
I'm trying to model fish capture success using length, velocity and
group composition as explanatory variables, density as an offset
Model1<-glmer(capture~length+offset(density)+(1|fish.id),family=binomi
al,dat
a=cap)
Model failed to converge with max|grad| = 0.260123 (tol = 0.001, component
1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
- I only get the warnings when I use length and group composition,
not with velocity.
- I don't get any warning if I don't use the offset.
Model1<-glmer(capture~length+offset(log(density))+(1|fish.id.c),family
=binom
ial(link="cloglog"),data=cap)
But still get the warning.
Any ideas of what might be the problem?
Many thanks!
Joana Martelo
Melhores cumprimentos,
Joana Martins
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
---
Este e-mail foi verificado em termos de vírus pelo AVG.
http://www.avg.com
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Loading...