padrinoDB / ipmr

Flexibly implement Integral Projection Models (IPMs)
https://padrinoDB.github.io/ipmr/
Other
6 stars 4 forks source link

Differing mesh sizes for adults and juveniles #72

Open TobyEAuckUni opened 1 month ago

TobyEAuckUni commented 1 month ago

Hi,

I am trying to create an IPM for kauri (Agathis australis) as part of my PhD and I have split the trees up into adults (Diameter over 2.5cm) and saplings/seedlings (Diameter under 2.5 cm). The measurement variable is height for the saplings, and DBH for the adults. I am currently trying to build an IPM with 10,000 classes for the adults, and 1,000 for the saplings/seedlings, as the sapling/seedling stage only represents a small portion of the life cycle of kauri. However, when I try this, the lambda is too high to be feasible and the fecundity kernel is not correct, as it creates juveniles/seedlings in class 1-10 (as expected), but also class 100-110, 200-210 etc. Is there any way that I can go about fixing this, or correcting for this? (e.g. adjusting the fecundity kernel in R to change these values to 0 after the model is built?)

Thank you for creating this package, it is great, I am quite new to coding and population modelling and found it very user friendly!

Kind Regards,

Toby Elliott

levisc8 commented 1 month ago

Hi Toby, Thanks for opening this up - I'm glad you're using the package! Rather than manually correct the kernels, it may be better to double check that the fecundity kernel is specified correctly (it sounds like there might be an indexing error). Do you mind sharing the IPM code and the parameters in the data_list (no need to share the raw data)? This would help work out the best way to fix the issue you're facing.

TobyEAuckUni commented 1 month ago

Hi Sam,

Thank you for your reply! I have played around a bit and can’t seem to get it.

I have attached my code below; my raw data is messy, but I can send it through if needed (or the workspace image). I have cleaned it a bit, but let me know if you have any questions; I have also sent through my fecundity kernel. I set the sapling/seedling kernel to have 500 classes for this example and for the adult kernel to have 1000 classes (to make it fast to compute) - but I will put it at 10000 (adults) and 5000 (saplings) for the final model as any coarser causes issues with the eviction function.

I have also attached the fecundity kernel as well, let me know if you have any questions and thank you so much again.

Kind Regards,

Toby Elliott.



On 9/06/2024, at 1:45 AM, Sam Levin @.***> wrote:

Hi Toby, Thanks for opening this up - I'm glad you're using the package! Rather than manually correct the kernels, it may be better to double check that the fecundity kernel is specified correctly (it sounds like there might be an indexing error). Do you mind sharing the IPM code and the parameters in the data_list (no need to share the raw data)? This would help work out the best way to fix the issue you're facing.

— Reply to this email directly, view it on GitHub https://github.com/padrinoDB/ipmr/issues/72#issuecomment-2156042902, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJAJRUJ53IK5DHF6FFGSYQDZGMDHLAVCNFSM6AAAAABI55V7NWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGA2DEOJQGI. You are receiving this because you authored the thread.

slevin-pivotbio commented 1 month ago

Hi Toby, (Sam here - using my work GH username). It looks like the code didn't attach properly. I don't think email attachments are preserved when replying to GitHub emails, so you may need to copy+paste the code itself into email response, or pop over to GitHub and attach it directly to your comment.

TobyEAuckUni commented 1 month ago

Hi Sam,

Apologies about that, I have uploaded the .txt file of the code here, Github doesn't seem to support R files, but thank you again for this help!

Kind Regards,

Toby.

Elliott_IPMr.txt

levisc8 commented 1 month ago

Just looked at the code. Are you saying that you want the recruit sizes to max out at the 10th size class? If so, you might need to modify the "fecundity" kernel like so:

recruit_size_dist = ifelse(HGT_2 =< INSERT_MAXIMUM_HEIGHT_HERE, 
                           dnorm(Hgt_2, IX_Asym_Recruit_height.mean, IX_Asym_Recruit_height.sd),
                           0)

right now, there is only a minimum DBH for being reproductive, so the model doesn't know that it shouldn't make recruits that are larger than you'd expect (only that the recruits have some mean and variance, and the tails of that distribution may extend to unrealistic heights). Does that make sense?

TobyEAuckUni commented 1 month ago

Hi Sam,

Thank you for the suggestion; I have had a go, and unfortunately, setting the upper limit for the saplings didn't seem to work. I have tried with different population states and have still had no luck. I have included a screenshot of one of my kernels, (with 500 sapling classes and 1000 adult classes to speed things up a bit). It correctly does the distribution at sapling classes 1 - 5 but repeats the exact distribution at classes 251 - 255. I tried with 100 sapling classes and 1000 adult classes, and it repeated the initial distributions 10x down the page.

Sorry about all this, and thank you again for your help!

Kind Regards,

Toby.

1-6 251-500

levisc8 commented 1 month ago

Ok, do you mind sending me the raw data you're using as well? You can send it to levisc8@gmail.com. That'll help me figure out what is going on internally