function jscale = set_jscale(estim_params_, mh_jscale_default)

% Builds the per-parameter MCMC jump-scale vector from the estimated
% parameters block. NaN entries (unspecified by the user) are replaced by
% the provided scalar default.
%
% INPUTS
% - estim_params_      [struct]  Estimated parameters block.
% - mh_jscale_default  [double]  Scalar default jump scale
%                                (typically options_.mh_jscale).
%
% OUTPUTS
% - jscale             [double]  n×1 vector of jump scales, one entry per
%                                estimated parameter, in the same order as
%                                xparam1 (stderr shocks, stderr measurement
%                                errors, corr shocks, corr measurement
%                                errors, skew shocks, endo init vals,
%                                structural params).

% Copyright © 2026 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare.  If not, see <https://www.gnu.org/licenses/>.

jscale = [];
if estim_params_.nvx
    jscale = [jscale; estim_params_.var_exo(:,10)];
end
if estim_params_.nvn
    jscale = [jscale; estim_params_.var_endo(:,10)];
end
if estim_params_.ncx
    jscale = [jscale; estim_params_.corrx(:,11)];
end
if estim_params_.ncn
    jscale = [jscale; estim_params_.corrn(:,11)];
end
if estim_params_.nsx
    jscale = [jscale; estim_params_.skew_exo(:,10)];
end
if estim_params_.nendoinit
    jscale = [jscale; estim_params_.endo_init_vals(:,10)];
end
if estim_params_.np
    jscale = [jscale; estim_params_.param_vals(:,10)];
end

jscale(isnan(jscale)) = mh_jscale_default;
