Actually, the correct solution is

 

if options_.prefilter == 1

    if options_.missing_data

        data=rawdata;

        bayestopt_.mean_varobs = zeros(n_varobs,1);

        for variable=1:n_varobs

            rdx = find(~isnan(rawdata(:,variable)));

            m = mean(rawdata(rdx,variable));

            data(rdx,variable) = rawdata(rdx,variable)-m;

            bayestopt_.mean_varobs(variable) = m;

        end

    else

        bayestopt_.mean_varobs = mean(rawdata,1)';

        data = rawdata-repmat(bayestopt_.mean_varobs',gend,1);

    end

else

    data=rawdata;

end

% Transpose the dataset array.

data = transpose(data);

 

I pushed the fix to the 4.2 branch.

 

Best, Johannes

 

 

--------

Johannes Pfeifer

Haußerstr. 29

72076 Tübingen

Tel.: +49-(0)7071-6396184

Mobil: +49-(0)170-6936820

jpfeifer@gmx.de

 

Von: Johannes Pfeifer [mailto:jpfeifer@gmx.de]
Gesendet: Freitag, 11. Mai 2012 20:14
An: List for Dynare developers (dev@dynare.org)
Betreff: Bug in dynare_estimation_init in 4.2.5

 

Dear all,

 

dynare_estimation_init.m in 4.2.5 currently reads

 

if options_.prefilter == 1

    if options_.missing_data

        bayestopt_.mean_varobs = zeros(n_varobs,1);

        for variable=1:n_varobs

            rdx = find(~isnan(rawdata(:,variable)));

            m = mean(rawdata(rdx,variable));

            rawdata(rdx,variable) = rawdata(rdx,variable)-m;

            bayestopt_.mean_varobs(variable) = m;

        end

    else

        bayestopt_.mean_varobs = mean(rawdata,1)';

        rawdata = rawdata-repmat(bayestopt_.mean_varobs',gend,1);

    end

end

% Transpose the dataset array.

data = transpose(rawdata);

 

Hence, rawdata is overwritten with the demeaned data. This leads to wrong smoother plots. The corresponding part should be:

 

if options_.prefilter == 1

    if options_.missing_data

        data=rawdata;

        bayestopt_.mean_varobs = zeros(n_varobs,1);

        for variable=1:n_varobs

            rdx = find(~isnan(rawdata(:,variable)));

            m = mean(rawdata(rdx,variable));

            data(rdx,variable) = rawdata(rdx,variable)-m;

            bayestopt_.mean_varobs(variable) = m;

        end

    else

        bayestopt_.mean_varobs = mean(rawdata,1)';

        data = rawdata-repmat(bayestopt_.mean_varobs',gend,1);

    end

end

% Transpose the dataset array.

data = transpose(data);

 

I tried to push a fix for cherrypicking to 4.2 but I am not sure I succeeded.

 

Best,

 

Johannes

 

 

--------

Johannes Pfeifer

Haußerstr. 29

72076 Tübingen

Tel.: +49-(0)7071-6396184

Mobil: +49-(0)170-6936820

jpfeifer@gmx.de