Thanks.

For those interested, below is the code snippet of my interpretation of `looping over a calibrated smoother’ in a single mod-file using @#for-loop.

[code]

%

% Observed variables

%

varobs ym1, ym2, ym3; % GDP, Credit and Prices series

%----------------------------------------------------------------

% 5. Bayesian estimation

%----------------------------------------------------------------

verbatim;

% define real-time matrices

% variable 1

trend1=nan(100,100);

slope1=nan(100,100);

cycle1=nan(100,100);

% variable 2

trend2=nan(100,100);

slope2=nan(100,100);

cycle2=nan(100,100);

% variable 3

trend3=nan(100,100);

slope3=nan(100,100);

cycle3=nan(100,100);

end;

options_.console_mode=1; %(default: 0)

@#for mysample in 21:85

estimation (

nobs=@{mysample}], % 21:85

datafile = lv_3data_hhloans,

nodisplay,

nograph,

graph_format = pdf,

nodiagnostic,

diffuse_filter,

kalman_algo = 0,

mh_replic = 0,

mh_nblocks = 1,

filtered_vars,

smoother,

mode_file=multiv_uoc_lv_hhloans6_mode,

mode_compute = 0,

plot_priors = 0,

forecast = 0

) mmu1 mmu2 mmu3 car1 car2 car3;

%----------------------------------------------------------------

% 6. Reporting

%----------------------------------------------------------------

%

% use this for verbatim mode

mynobs=@{mysample};

verbatim;

for i = 1:3

%if laplace only

% get the smoothed trend and cycle

%eval( ‘ym_ = ym’ num2str(i) ‘;’ ]);

eval( ‘trend_ = oo_.SmoothedVariables.mmu’ num2str(i) ‘;’ ]);

eval( ‘cycle_ = oo_.SmoothedVariables.car’ num2str(i) ‘;’ ]);

% eval( ‘irreg_ = oo_.SmoothedShocks.e_irr’ num2str(i) ‘;’ ]);

```
% form a matrix of real time estimates
eval( 'trend' num2str(i) '(1:mynobs,mynobs-20)= trend_;']);
eval( 'slope' num2str(i) '(2:mynobs,mynobs-20)= diff(trend_);' ]);
eval( 'cycle' num2str(i) '(1:mynobs,mynobs-20)= cycle_;' ]);
```

end;

end;

@#endfor

% plot all real-time cycles for variable 1 (GDP)

figure(1)

plot(cycle1)

% extract only t|t, t|t+4, t|t+12 and t|t+20

verbatim;

% t|t estimate

mystep=0;

cycle1_t_t=nan(100,1);

for ii=21:85-mystep

cycle1_t_t(ii)=cycle1(ii,ii-20+mystep);

end

% t|t+4 estimate

mystep=4;

cycle1_t_tp4=nan(100,1);

for ii=21:85-mystep

cycle1_t_tp4(ii)=cycle1(ii,ii-20+mystep);

end

% t|t+12 estimate

mystep=12;

cycle1_t_tp12=nan(100,1);

for ii=21:85-mystep

cycle1_t_tp12(ii)=cycle1(ii,ii-20+mystep);

end

% t|t+20 estimate

mystep=20;

cycle1_t_tp20=nan(100,1);

for ii=21:85-mystep

cycle1_t_tp20(ii)=cycle1(ii,ii-20+mystep);

end

figure(2)

plot(cycle1_t_t,’:black’)

hold on;

plot(cycle1_t_tp4,’-.black’)

plot(cycle1_t_tp12,’–red’)

plot(cycle1_t_tp20,‘red’)

hold off;

legend(‘t|t’,‘t|t+4’,‘t|t+12’,‘t|t+20’)

end;[/code]

64 iterations plus plots go in 16sec.