This is probably a stupid question. I am trying to run the example code on the dynare manual pg 122, which shows the filtered series using the Baxter-King band pass filter.
My question is, is that example complete? I.e. do you just create a mod file with just those lines and run it through dynare? When I do so dynare crashes with the following error message:
ERROR: ts_model.mod: line 21, col 1 - line 28, col 0: syntax error, unexpected $end
Could anyone clarify this please?
No, this is actually Matlab code. You can attach this code to a regular mod-file (you may need to wrap it in a verbatim-block).
% Simulate a component model (stochastic trend, deterministic trend, and a
% stationary autoregressive process).
e = .2*randn(200,1);
u = randn(200,1);
stochastic_trend = cumsum(e);
deterministic_trend = .1*transpose(1:200);
x = zeros(200,1);
x(i) = .75*x(i-1) + e(i);
y = x + stochastic_trend + deterministic_trend;
% Instantiates time series objects.
ts0 = dseries(y,'1950Q1');
ts1 = dseries(x,'1950Q1'); % stationary component.
% Apply the Baxter-King filter.
ts2 = ts0.baxter_king_filter();
% Plot the filtered time series.
plot(ts1(ts2.dates).data,'-k'); % Plot of the stationary component.
plot(ts2.data,'--r'); % Plot of the filtered y.
id = get(gca,'XTick');
as a Matlab m-file
Thank you, that works!
I had tried running it as a matlab code using F9 first, but it wouldn’t run. I now realize it may have partly been because of a typo in the last line, which you corrected in your version.
The thing is that you need the
dseries objects in your path. If you did not run Dynare before in your Matlab-session and have only the
dynare/matlab-folder in your path, you need to run
before you can use