-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relaxed-rate model cannot take Inf K as initial parameter #159
Comments
I think this error only occurs if you choose K as your relaxed parameter in
which case setting the mean to Inf makes no sense.
Op ma 2 okt. 2023 09:38 schreef Joshua Lambert ***@***.***>:
… When running the relaxed-rate DAISIE model with an initial value of Inf
for the carrying capacity ($K$) I get the error show in the following
reprex:
library(DAISIE) #package version 4.4.0
data("Galapagos_datalist")
# example rr model code that works fine (k is 50)
# res <- DAISIE::DAISIE_ML_CS(# datalist = Galapagos_datalist, # initparsopt = c(1.5, 1.5, 50, 0.01, 1.5, 0.5), # idparsopt = 1:6, # parsfix = NULL, # idparsfix = NULL,# ddmodel = 11, # optimmethod = "simplex", # CS_version = DAISIE::create_CS_version(# model = 2, # relaxed_par = "carrying_capacity", # par_sd = 1, # par_upper_bound = Inf# )# )
# example that breaks because of inf starting k
res <- DAISIE::DAISIE_ML_CS(
datalist = Galapagos_datalist,
initparsopt = c(1.5, 1.5, Inf, 0.01, 1.5, 0.5),
idparsopt = 1:6,
parsfix = NULL,
idparsfix = NULL,
ddmodel = 11,
optimmethod = "simplex",
CS_version = DAISIE::create_CS_version(
model = 2,
relaxed_par = "carrying_capacity",
par_sd = 1,
par_upper_bound = Inf
)
)#> Error in seq.default(log(par_mean) - 1, log(par_mean) + 1): 'from' must be a finite number
Created on 2023-10-02 with reprex v2.0.2 <https://reprex.tidyverse.org>
The issue is caused by these lines in the DAISIE_loglik_integrate()
function:
https://github.com/rsetienne/DAISIE/blob/master/R/DAISIE_loglik_integrate.R#L33-L35
Annoyingly at the moment I cannot compile the DAISIE package locally on my
mac so I'm unable to work on a fix right now.
Two initial options I see are:
1. My preferred option is to modify the lines causing the issue and
create the xx vector when the relaxed parameter is infinite. One
possible problem would be that the Inf parameter value might be
outside the range of this vector as a result and the integration may then
be incorrect.
2. Check if the relaxed parameter is infinite (is.infinite()) at the
start of this function and if so change it to be an arbitrarily large
finite number (e.g. 1e10). I don't think this is the best option as it
might have unintended downstream consequences and bias parameter estimation.
This might require some more exploration about how the relaxed-rate model
is handling (integrating) infinite parameter values. As I say I can't find
a fix atm due to not being able to compile the package and debug line by
line, but will try to look into it asap.
—
Reply to this email directly, view it on GitHub
<#159>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADMTHGJ5CRH7EOXZBTPR723X5JVQNANCNFSM6AAAAAA5PAK2DE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Do you agree this is the case for all relaxed parameters and not just One other thing to consider is what happens if the initial parameter is finite by the optimiser pushes the parameter to be infinite. I don't think I've come across this situation, but I can take a look through the simplex traces and see if it occurs. It's not something that needs to be tackled in this issue and if it is a problem I will log it in a separate issue. |
For context, the reason I found this error was not manually choosing It is an easy fix to make sure that the relaxed-rate model is not being supplied with |
Yes, in principle this applies to all parameters, but Inf for the others
makes no sense whatsoever.
Values stay finite during optimization. They can get large but I don't see
how they can become truly infinite.
Op ma 2 okt. 2023 09:51 schreef Joshua Lambert ***@***.***>:
… Do you agree this is the case for all relaxed parameters and not just $K$?
If so I can make a change to the code that checks whether the user has
supplied Inf as the relaxed parameter mean and throw an error stating
that this should not be done.
One other thing to consider is what happens if the initial parameter is
finite by the optimiser pushes the parameter to be infinite. I don't think
I've come across this situation, but I can take a look through the simplex
traces and see if it occurs. It's not something that needs to be tackled in
this issue and if it is a problem I will log it in a separate issue.
—
Reply to this email directly, view it on GitHub
<#159 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADMTHGPT7YIYE2EK3F6CF73X5JXBTANCNFSM6AAAAAA5PAK2DE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Closing this issue as it was resolved in PR #160. |
When running the relaxed-rate DAISIE model with an initial value of$K$ ) I get the error show in the following reprex:
Inf
for the carrying capacity (Created on 2023-10-02 with reprex v2.0.2
The issue is caused by these lines in the
DAISIE_loglik_integrate()
function: https://github.com/rsetienne/DAISIE/blob/master/R/DAISIE_loglik_integrate.R#L33-L35Annoyingly at the moment I cannot compile the DAISIE package locally on my mac so I'm unable to work on a fix right now.
Two initial options I see are:
xx
vector when the relaxed parameter is infinite. One possible problem would be that theInf
parameter value might be outside the range of this vector as a result and the integration may then be incorrect.is.infinite()
) at the start of this function and if so change it to be an arbitrarily large finite number (e.g.1e10
). I don't think this is the best option as it might have unintended downstream consequences and bias parameter estimation.This might require some more exploration about how the relaxed-rate model is handling (integrating) infinite parameter values. As I say I can't find a fix atm due to not being able to compile the package and debug line by line, but will try to look into it asap.
The text was updated successfully, but these errors were encountered: