I have written the code of my model in exp() form.
But if I want to calculate welfare loss like W={{\lambda }_{1}}\operatorname{var}\left( {{\pi }_{t}} \right)+{{\lambda }_{2}}\operatorname{var}\left( {{y}_{t}} \right), do I need to transfer the code to level form and then use order=2 option? Or just use exp() form and order=2 option? Are the value of \operatorname{var}\left( {{\pi }_{t}} \right) and \operatorname{var}\left( {{y}_{t}} \right) identical or not in these two cases?

And also, I see in many papers the values of {{\lambda }_{1}} and {{\lambda }_{2}} are sometimes subjective. Is it proper to set the value like this and do robustness test?

Looking forward to your reply and thank you for your time.

Yes, there is obviously a difference in standard deviations for the level as opposed to percentage deviations. If you use auxiliary variables, you can have both objects in your model.

It depends whether you want to work with an ad-hoc loss function or a micro-founded one based on agents in the model.

To the first question, Are there any differences in economic meaning between the values I gain in these two cases? Which case is more generally used?

And I have got two new problems as follows when typing the code.
(1)What should be the correct definition of output gap in dynare code if I use exp() form?
Is outputgap=exp(y(t))-exp(ystar(t));
correct？

(2) How to deal with taylor rule equation in the code with both sticky and flexible price?
I write both the two equations in the code while only one has monetary policy shock in it(as follows). Is it correct?

What do you mean? Percentage deviations are unitless and have an easy interpretation. That’s often not the case for levels, which depend on the units/scaling. For that reason, logs are typically used.

If monetary neutrality holds in the flex-price model, then whether you include the shock or not does not matter. That being said, leaving it out is a lot more common.

Sorry if I did not make it clear. For instance, when I calculate welfare loss under level form, I use piU_pos=strmatch('piU',var_list_ ,'exact'); variance.piU=oo_.var(piU_pos,piU_pos);
and y_gapU_pos=strmatch('y_gapU',var_list_ ,'exact'); variance.y_gapU=oo_.var(y_gapU_pos,y_gapU_pos);
in which piU is the level form of inflation and y_gapU=yU-y_natureU. Welfare loss is caculated by welfare=variance.piU+0.05*variance.y_gapU;
and the value is 0.06. (Please point out if I make any mistake in the process as I’m really not familiar with this)
While when I calculate welfare loss under log-level form, I use log_piU_pos=strmatch('log_piU',var_list_ ,'exact'); variance.log_piU=oo_.var(log_piU_pos,log_piU_pos);
and y_gapU_pos=strmatch('y_gapU',var_list_ ,'exact'); variance.y_gapU=oo_.var(y_gapU_pos,y_gapU_pos);
in which log_piU=log(piU) and y_gapU=(yU-y_natureU)/y. Welfare loss is caculated by welfare=variance.log_piU+0.05*variance.y_gapU;
and the value is 0.00005. (Also please point out if I make any mistake in the process)
Is there any difference in economic meaning between these two values(0.6 and 0.00005)?

So the definition equation of outputgap in level form is written as y_gapU=yU-y_natureU and y_gapU=(yU-y_natureU)/y in log-level form, did I make it correctly?

If I do not include the taylor rule equation under flex-price situation, It seems there is a lack of one equation. Do I misunderstand anything?

Looking forward to your reply and thanks again for your precious time.

Yes, that makes a difference. Only one of the two formulations is correct. Your model should determine whether the welfare loss is a function of the levels or the logs. Usually, it is the logs, because it is derived from a log approximation to utility.

If both have the same steady state, then yes.

The Taylor rule will only affect inflation, but nothing else. So you could write down the flex-price model purely in real terms.

To the 3rd question, what’s the meaning of “write down the flex-price model purely in real terms”?

And also, I see in some papers that output gap(in welfare loss function) is just treated as the deviation from the steady state instead of nature output. Is it proper to deal with it like this?

In a developing country with relatively high output growth, is it more advisable using y(t)/y(t-1) instead of y(t)/y in the Taylor Rule?

Flex price equilibria can usually be written down with referring to any nominal variables. For example. all that matters will be the real interest rate. But if that is too complicated, having a Taylor rule will give the same results. See e.g. DSGE_mod/Gali_2015_chapter_2.mod at master · JohannesPfeifer/DSGE_mod · GitHub

It depends on what you are trying to do. The relevant welfare losses for optimal policy concern deviations from natural output (the efficient allocation), not steady state. What @HelloDynare refers to is a positive description of reality. Natural output is unobserved so that central banks often employ a gap measure with respect to something observable like the steady state. But it would not be valid to use this measure for a microfounded welfare analysis.

Again, this is a matter of your objective. If you want to describe behavior of the central bank, check which rule better describes the actual behavior.