thouska / spotpy

A Statistical Parameter Optimization Tool
https://spotpy.readthedocs.io/en/latest/
MIT License
256 stars 152 forks source link

Can we add a penalty term to the likelihood function? #278

Open BeingHapppy opened 3 years ago

BeingHapppy commented 3 years ago

Hi, everyone!

I am using the dream method in spotpy to calibrate crop growth model.

I only have crop yield data as observation to build likelihood function but I also wish the simulated leave dynamics(max LAI) in the plausible range(3-7). So I am wondering whether " is it possible to add a penalty term to the likelihood function based on the simulation value?"

I know this is because 1. my observation data is so little and 2. it is hard for me to set parameters range. I'm not too familiar with the Bayesian method,any suggestion will be appreciated.

thouska commented 3 years ago

Hi @BeingHapppy

thank you for your message and for using spotpy.

Do you have a particular method in mind that should be implemented. If so, I could check out the reference and see what I can do. If not, why not using the likelihood funtion as it is with your crop yield data and alter it, however you like, based on the LAI value. Maybe something like this:

def objectivefunction(self,simulation,evaluation):

LAI_penality_factor = 1.5 crop yield = simulation[0] LAI = simulation[1] like = spotpy.likelihoods.gaussianLikelihoodMeasErrorOut(evaluation, crop_yield) if LAI<3 or LAI>7: like=like*LAI_penality_factor return like

I guess one could also come up with a more dynamical penality factor.

BeingHapppy commented 3 years ago

Thank you @thouska. I haven't figured out a better way than the one you proposed. I tried to use the magic number -9999: once the simulation is not as wished, the like value will be set as -9999. It is really a bad way, the value of the likelihood function inevitably changes drastically with sampling in some situation. So, I will try your suggestion now :)