# Grid Calculation of Loss Function Values

Dear All,
I am trying to calculate loss function values for two different parameter values. I have a code on matlab (which is a bad modification of any other code I found in this forum) but I am not good at matlab. In loop3.m file, I don’t know how to write my loss function and store it and get the values (as a table or graph or any other way) in this loop.
My loss function will be like L=(1/2*variance.Y+variance.P+variance.b);
How can I get these loss function values for different parameters,
loop3.m (572 Bytes)
RRendiss.mod (3.1 KB)
Any help will be highly appreciated. Thanks

Try loop3.m (794 Bytes)
But you need to fix the parameter dependence in your mod-file first. Use model-local variables.

1 Like

Dear jpfeier,
Thanks a lot for reply.
I am trying to understand model-local variables now.
As I understood, these variables should be defined in the model part as
# VARIABLE_NAME = MODEL_EXPRESSION;
What should I do is still ambiguous to me. Which equations or variables should be used as model-local variables? And is it related to Steady State levels, should I change them too?
More importantly, am I finding wrong parameter values with osr command when I don’t use model local variables?
Thanks a lot.

It’s about the composite parameters set before the `model`-command :

``````RbSS=(BETAS*(1-gama*(1-RRRss))+BETAF*gama)/(BETAS*BETAF);
z1=J/(1-BETAS);                                     %qHstoCs
z2=J*RbSS/((1-BETAB)*RbSS-Kss*(1-BETAB*RbSS));     %qHbtoCb
z3=(J*Kss)/(RbSS*(1-BETAB)-Kss*(1-BETAB*RbSS));       %bSStoCbSS
z4=1-(1-RbSS)*(z3);                                %NbwbtoCb