hmorlon / PANDA

Phylogenetic ANalyses of DiversificAtion
24 stars 15 forks source link

time * environmental interaction model? #21

Closed melisaolave closed 5 years ago

melisaolave commented 5 years ago

Hello, this is not an issue but a question of fit_env application. I'm wondering if it is possible to include a model with lambda and/or mu varying in time in addition to an environmental effect using fit_env. That would be a case where lambda depends on both time and environment. I don't think this has been done, or at least couldn't find any example in the literature or manual (but maybe I'm missing it?). I got this model and just want to check if RPANDA is doing what "I want" or if I'm missing/misunderstanding something:

f.lamb <-function(t,x,y){ y[1] exp(y[2] t x) ### exponential example of time environmental interaction? } f.mu<-function(t,x,y){ y[1] + y[2] t x ### linear example of time environmental interaction? } lamb_par<- c(0.1, 0.01) mu_par <- c(0.1, 0.01) result <- fit_env(phylo = tree, env_data = env_data, tot_time = tot_time, f.lamb=f.lamb, f.mu = f.mu, lamb_par = lamb_par, mu_par = mu_par, expo.lamb = T, dt=1e-3)

Thanks a lot in advance!!

hmorlon commented 5 years ago

Hello Melisa, yes absolutely, you can have lamda/mu varying as a function of both time and the environment, as written in the Condamine et al. Eco Lett 2013 (see Box1). Note though, as you said, that we did not test the performance of the model (ability to recover simulated values, proper model, etc, as we did for environment-only models in the Lewitus & Morlon Syst Bio 2018 paper) for these models. So, in case you want to use such a model for an empirical application, i recommend that you test it first on simulated data, at least for a limited set of parameter values. I also recomment that you leave the expo.lamb, expo.mu and so on options to FALSE, or double check carefully that Phi and Psi are computed properly when using these options in the case of a dependence on t and the environment. I hope this helps. Best Hélène

melisaolave commented 5 years ago

Perfect, thanks a lot for your response!