stoufferlab / general-functional-responses

Code (and most data) for two manuscripts about consumer functional responses
MIT License
2 stars 0 forks source link

Generating a single prediction for replicate treatments #132

Closed stouffer closed 4 years ago

stouffer commented 4 years ago

Right now we generate a new prediction for every replicate, even when the experimental treatment is equivalent. This isn't much of an issue except for 1pred2prey where we numerically integrate for every observation. This means we do n-1 extra integrations for a treatment that has n replicates, and this bogs down everything (especially fitting and profiling).

I have tried to change this in holling.like.1pred.2prey.NLL but my attempt to merge appears to reorder things which causes issues when calculating the likelihood. I will make a branch where this can be tested and improved, but am going to leave it aside for the time being because the existing approach, while slow, works.

stouffer commented 4 years ago

Tinkering and solving of this should occur here.

stouffer commented 4 years ago

Correction. The appropriate places to implement this are in the .predict functions, not the .NLL functions.

stouffer commented 4 years ago

While playing around with this, I have learned that embedding any solution in the *.predict functions slows things down tremendously. I believe this is because it is costly in R to create/destroy the data frames that we would use for unique/merge. For now, it's actually faster to avoid this process and predict each observation separately even if they are replicates. If we actually want to introduce this improvement, we will need to rethink the way to go about it. Otherwise, the ostensible speed up will just become a speed down. (That is, we are not computer scientists.)

stouffer commented 4 years ago

Given current structure of the code, this is infeasible and also not strictly required.