I have a question about how to connect the data to model variables in the estimation.

If my data is H-P filtered, then the mean of these data is zero. However, the steady states of relavant variables in the model are not equal to zero. Can I simply generate a new variable, which is equal to gap between the variable and its steady state. And then connect this new variable to the
H-P filtered data?

do not do that at all. This is almost always complete nonsense.

What I/we do, we observe log levels and accommodate models with additional technologies explaining stationary (or even non-stationary) relative prices, if a model is not mean to endogenously explain stationary (or non-stationary) parts of relative prices. The same holds for non-stationary labor shares in transition countries, investement share, etc, etc.

The basic reason for not using HP-filter is the following: by using HP you just select some frequencies and throw out the rest and lose low frequency information which is implied mainly by these technologies. This has at least two bad implications: First, correlation of the variables explainable by these supply shocks is left in the data and must be explained with other shocks, this is an error implied by univariate nature of HP. It often completely spoils estimation of monetary policy or preference shocks, since these demand shocks are required to handle the left-overs of supply shocks. Second, the high frequency behaviour of agents depends strongly on their inference what level of technology they enjoy now and how long the party/suffering would continue. If you drastically cut-off this supply information, the model will not catch this high-frequency behaviour. Note that this an implication of non-linearity of autocorrelation of technological processes.

Secondary reason of not using HP is that it is not necessary.

All in all, I think you should not use HP at all. It is first (in many cases) non-sense, second it is not fun. You will not learn as much as you could.

No, Log of GDP is growing, detrended GDP by HP (we should detrend log GDP) is not growing.

Another more practical argument against ad-hoc detrending:

Say you have a data for a country after disinflation, say you have a simple gap model describing transition from nominal interest rates to real interest rates (through backward looking inflation) to real economy (output gap) and to inflation. What is the output gap during the sample? Right, negative in average, because of the disinflation. What is the output gap as a result of HP (or other ad-hoc) detrending? Correct, zero in average. Who is to be blamed, the model with the Phillips curve or HP filter? One who uses HP filter should be blamed. In this simple framework, Log GDP is a sum of euqilibrium GDP and the gap, equilibrium corresponds to supply, gap to demand. Using univariate filter to split Log GDP to these two components is clearly non-sense.

i think i was not clear enough. suppose the model is fully stationary, without a unit root shock that gives growth. then will the demeaned or detrended observables, correspond with a log-deviation from steady state? i am not refered to an output gap or so.
take consumption for example. is not C-hat a detrended version of a level data series on consumption C?
of course if there is growth in the model, detrending the observables would not make any sense.
am i misunderstanding something?

If there is no growth in the model, then data should be detrended. What
Ondra is trying to say is that data should not be H-P filtered, linear detrend is OK.

If we enter the model equations in log-linear form: for example

exp(y)=exp(A)exp(h)^alphaexp(k(-1))^(1-alpha)

A=(1-rhoa)Astar+rhoaA(-1)+aa;

Let’s say we observe y and h.
I think detrended logrithem data correspond to the percentage deviation from the steady state.
My question is: the steady state of h and y are not equal to zero( determinded by Astar and other parameters) , but the mean of detrended
data is equal to zero. Can I generate two new variables oy and oh
so that

oy=y-ystar;
oh=h-hstar;

where ystar and hstar are calculated steady state of y and h.

Now, assume we observe oy and oh, the steady state of oy and oh is zero, which matches the mean of detrended data.

The shortcoming of this method is that we cannot pin down some parameters like Astar, since oy and oh are not affected by the change of Astar.

Can you tell me what is your method to make sure the steady state of model variables matches the mean of observable data?

i never faced that problem. as i log-linearise by hand , and then enter the equations using the model(linear) option. so the ‘steady state’ of my models are zero, like in SW(2003) or in Lubik Schorfheide (2006). log-linearising by hand is a bit tedious, but the estimation goes much, much quicker. i also find it easier to understand the model when i linearise it myself instead of letting dynare do it.