diff --git a/doc/manual/source/dynare-misc-commands.rst b/doc/manual/source/dynare-misc-commands.rst index 66383a295..a04813927 100644 --- a/doc/manual/source/dynare-misc-commands.rst +++ b/doc/manual/source/dynare-misc-commands.rst @@ -8,6 +8,20 @@ Dynare misc commands #################### +.. matcomm:: send_endogenous_variables_to_workspace + + Puts the simulation results for the endogenous variables stored in ``oo_.endo_simul`` + into vectors with the same name as the respective variables into the base workspace. + +.. matcomm:: send_exogenous_variables_to_workspace + + Puts the simulation results for the exogenous variables stored in ``oo_.exo_simul`` + into vectors with the same name as the respective variables into the base workspace. + +.. matcomm:: send_irfs_to_workspace + + Puts the IRFs stored in ``oo_.irfs`` into vectors with the same name into the base workspace. + .. command:: prior_function(OPTIONS); Executes a user-defined function on parameter draws from the prior diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 583a9b5b8..34dc61b1c 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -4880,14 +4880,10 @@ Computing the stochastic solution If the ``periods`` option is present, sets ``oo_.skewness``, ``oo_.kurtosis``, and ``oo_.endo_simul`` (see - :mvar:`oo_.endo_simul`), and also saves the simulated variables in - MATLAB/Octave vectors of the global workspace with the same name - as the endogenous variables. + :mvar:`oo_.endo_simul`). If option ``irf`` is different from zero, sets ``oo_.irfs`` (see - below) and also saves the IRFs in MATLAB/Octave vectors of the - global workspace (this latter way of accessing the IRFs is - deprecated and will disappear in a future version). + below). If the option ``contemporaneous_correlation`` is different from ``0``, sets ``oo_.contemporaneous_correlation``, which is @@ -5096,10 +5092,13 @@ Computing the stochastic solution For example, ``oo_.irfs.gnp_ea`` contains the effect on ``gnp`` of a one-standard deviation shock on ``ea``. -.. matcomm:: get_irf ('EXOGENOUS_NAME' [, 'ENDOGENOUS_NAME']... ); +.. matcomm:: IRF_MATRIX=get_irf ('EXOGENOUS_NAME' [, 'ENDOGENOUS_NAME']... ); - |br| Given the name of an exogenous variables, returns the IRFs for the - requested endogenous variable(s), as they are stored in ``oo_.irfs``. + |br| Given the name of an exogenous variable, returns the IRFs for the + requested endogenous variable(s) (as they are stored in ``oo_.irfs``) in the output + ``IRF_MATRIX``. The periods are stored along the first dimension, with the steady + state in the first row. The variables are stored along the second dimension. If no + endogenous variables were specified, the matrix contains all variables stored in ``oo_.irfs``. The approximated solution of a model takes the form of a set of decision rules or transition equations expressing the current value of diff --git a/matlab/accessors/get_irf.m b/matlab/accessors/get_irf.m index 0d0ae68f8..363d88d09 100644 --- a/matlab/accessors/get_irf.m +++ b/matlab/accessors/get_irf.m @@ -1,20 +1,19 @@ - -function y0 = get_irf(exo,varargin) -% function x = get_irf(exoname, vname1, vname2, ...) +function y0 = get_irf(exoname,varargin) +% function x = get_irf(exoname, varargin) % returns IRF to individual exogenous for a list of variables and adds the % steady state % % INPUTS: -% exo: exo variable name +% exoname: exo variable name % vname1, vname2, ... : list of variable names % % OUTPUTS -% x: irf matrix [time x number of variables] +% y0: irf matrix [time x number of variables] % % SPECIAL REQUIREMENTS % none -% Copyright © 2019 Dynare Team +% Copyright © 2019-2023 Dynare Team % % This file is part of Dynare. % @@ -33,14 +32,44 @@ function y0 = get_irf(exo,varargin) global M_ oo_ -ys_ = [oo_.steady_state]; -y0=zeros(length(oo_.irfs.([varargin{1} '_' exo]))+1,length(varargin)); - - -[i_var,nvar] = varlist_indices(varargin,M_.endo_names); - - -for j=1:nvar - % mfys = strmatch(varargin{j},lgy_,'exact'); - y0(:,j)=[0; oo_.irfs.([ varargin{j} '_' exo ])']+ys_(i_var(j)); +if isfield(oo_,'irfs') + irf_fields=fieldnames(oo_.irfs); +else + error('get_irf: No IRFs detected in oo_') end + +exo_matches=find(endsWith(irf_fields,['_' exoname])); +if isempty(exo_matches) + error('get_irf: No IRFs for shock %s detected in oo_',exoname) +else + if nargin>1 + endo_cell={}; + i_var=[]; + for var_iter=1:length(varargin) + temp=startsWith(irf_fields(exo_matches),varargin{var_iter}); + if isempty(temp) + fprintf('get_irf: No IRF for variable %s detected in oo_',varargin{var_iter}) + else + endo_cell=[endo_cell,varargin{var_iter}]; + i_var=[i_var,strmatch(varargin(var_iter),M_.endo_names,'exact')]; + end + end + else + endo_cell={}; + i_var=[]; + for var_iter=1:length(exo_matches) + endo_cell=[endo_cell,irf_fields{var_iter}(1:end-length(exoname)-1)]; + i_var=[i_var,strmatch(endo_cell(end),M_.endo_names,'exact')]; + end + end +end + +ys_ = [oo_.steady_state]; +nvars=length(endo_cell); +y0=zeros(length(oo_.irfs.([ endo_cell{1} '_' exoname ]))+1,nvars); + +for j=1:nvars + y0(:,j)=[0; oo_.irfs.([ endo_cell{j} '_' exoname ])']+ys_(i_var(j)); +end + + diff --git a/matlab/ep/extended_path.m b/matlab/ep/extended_path.m index 1cf7b5ff4..fe1bf640e 100644 --- a/matlab/ep/extended_path.m +++ b/matlab/ep/extended_path.m @@ -1,5 +1,5 @@ -function [ts, oo_] = extended_path(initialconditions, samplesize, exogenousvariables, options_, M_, oo_) -% [ts, oo_] = extended_path(initialconditions, samplesize, exogenousvariables, options_, M_, oo_) +function [ts,oo_] = extended_path(initialconditions, samplesize, exogenousvariables, options_, M_, oo_) +% [ts,oo_] = extended_path(initialconditions, samplesize, exogenousvariables, options_, M_, oo_) % Stochastic simulation of a non linear DSGE model using the Extended Path method (Fair and Taylor 1983). A time % series of size T is obtained by solving T perfect foresight models. % @@ -13,7 +13,7 @@ function [ts, oo_] = extended_path(initialconditions, samplesize, exogenousvaria % % OUTPUTS % o ts [dseries] m*samplesize array, the simulations. -% o results [cell] +% o results [struct] results structure % % ALGORITHM % @@ -106,9 +106,4 @@ if any(isnan(endogenous_variables_paths(:))) end ts = dseries(transpose(endogenous_variables_paths), initial_period, M_.endo_names); -oo_.endo_simul = transpose(ts.data); -assignin('base', 'Simulated_time_series', ts); - -if ~nargout || nargout<2 - assignin('base', 'oo_', oo_); -end +oo_.endo_simul = transpose(ts.data); \ No newline at end of file diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m index aa1802ec3..4a89e0f4f 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_solver.m +++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m @@ -1,4 +1,4 @@ -function oo_=perfect_foresight_solver(M_, options_, oo_, no_error_if_learnt_in_is_present, marginal_linearization_previous_raw_sims) +function [oo_, ts]=perfect_foresight_solver(M_, options_, oo_, no_error_if_learnt_in_is_present, marginal_linearization_previous_raw_sims) % Computes deterministic simulations % % INPUTS @@ -16,6 +16,7 @@ function oo_=perfect_foresight_solver(M_, options_, oo_, no_error_if_learnt_in_i % % OUTPUTS % oo_ [structure] storing the results +% ts [dseries] final simulation paths % % ALGORITHM % @@ -273,8 +274,6 @@ if ~isempty(per_block_status) oo_.deterministic_simulation.block = per_block_status; end -dyn2vec(M_, oo_, options_); - if isfield(oo_, 'initval_series') && ~isempty(oo_.initval_series) initial_period = oo_.initval_series.dates(1)+(M_.orig_maximum_lag-1); elseif ~isdates(options_.initial_period) && isnan(options_.initial_period) @@ -290,8 +289,6 @@ if isfield(oo_, 'initval_series') && ~isempty(oo_.initval_series) ts = merge(oo_.initval_series{names{:}}, ts); end -assignin('base', 'Simulated_time_series', ts); - oo_.gui.ran_perfect_foresight = oo_.deterministic_simulation.status; diff --git a/matlab/send_exogenous_variables_to_workspace.m b/matlab/send_exogenous_variables_to_workspace.m new file mode 100644 index 000000000..9814bcd40 --- /dev/null +++ b/matlab/send_exogenous_variables_to_workspace.m @@ -0,0 +1,25 @@ +function send_exogenous_variables_to_workspace() +% send_exogenous_variables_to_workspace() +% Saves all the endogenous variables in matlab's workspace. + +% Copyright © 2023 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 . +global M_ oo_ + +for idx = 1:M_.exo_nbr + assignin('base', M_.exo_names{idx}, oo_.exo_simul(:,idx)) +end \ No newline at end of file diff --git a/matlab/send_irfs_to_workspace.m b/matlab/send_irfs_to_workspace.m new file mode 100644 index 000000000..6753769f7 --- /dev/null +++ b/matlab/send_irfs_to_workspace.m @@ -0,0 +1,27 @@ +function send_irfs_to_workspace() +% Saves all the IRFs in MATLAB's workspace. + +% Copyright © 2023 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 . +global oo_ + +if isfield(oo_,'irfs') + irf_fields=fieldnames(oo_.irfs); + for irf_iter = 1:size(irf_fields,1) + assignin('base',irf_fields{irf_iter},oo_.irfs.(irf_fields{irf_iter})'); + end +end diff --git a/matlab/stochastic_solver/stoch_simul.m b/matlab/stochastic_solver/stoch_simul.m index 30278fd0c..3d0cc4e0f 100644 --- a/matlab/stochastic_solver/stoch_simul.m +++ b/matlab/stochastic_solver/stoch_simul.m @@ -197,9 +197,6 @@ if options_.periods > 0 && ~PI_PCL_solver end end [oo_.endo_simul, oo_.exo_simul] = simult(y0,oo_.dr,M_,options_); - if ~options_.minimal_workspace - dyn2vec(M_, oo_, options_); - end end if ~options_.nomoments @@ -267,8 +264,6 @@ if options_.irf mylistTeX = []; end for j = 1:nvar - assignin('base',[M_.endo_names{i_var(j)} '_' M_.exo_names{i}],... - y(i_var(j),:)'); oo_.irfs.([M_.endo_names{i_var(j)} '_' M_.exo_names{i}]) = y(i_var(j),:); if max(abs(y(i_var(j),:))) >= options_.impulse_responses.plot_threshold irfs = cat(1,irfs,y(i_var(j),:)); diff --git a/preprocessor b/preprocessor index 0f397f40a..638c49d96 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 0f397f40afd096b062010a374464aae1567ef623 +Subproject commit 638c49d96ee491a66ba775ffc79a1d6afbe8acfc diff --git a/tests/analytic_derivatives/fs2000_analytic_derivation.mod b/tests/analytic_derivatives/fs2000_analytic_derivation.mod index 02ce40955..9f694edda 100644 --- a/tests/analytic_derivatives/fs2000_analytic_derivation.mod +++ b/tests/analytic_derivatives/fs2000_analytic_derivation.mod @@ -62,6 +62,7 @@ var e_m; stderr 0.005; end; stoch_simul(order=1,periods=200, irf=0,nomoments,noprint); +send_endogenous_variables_to_workspace; save('my_data.mat','gp_obs','gy_obs'); estimated_params; diff --git a/tests/deterministic_simulations/pfwee.mod b/tests/deterministic_simulations/pfwee.mod index 8867998f7..0280b6053 100644 --- a/tests/deterministic_simulations/pfwee.mod +++ b/tests/deterministic_simulations/pfwee.mod @@ -46,7 +46,7 @@ verbatim; % Information arriving in period 1 (temp shock now) oo_.exo_simul(2,1) = 1.2; -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); % Information arriving in period 2 (temp shock now + permanent shock in future) oo_.exo_simul(3,1) = 1.3; @@ -59,7 +59,7 @@ saved_endo = oo_.endo_simul(:, 1); saved_exo = oo_.exo_simul(1, :); oo_.endo_simul = oo_.endo_simul(:, 2:end); oo_.exo_simul = oo_.exo_simul(2:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; @@ -74,7 +74,7 @@ saved_endo = oo_.endo_simul(:, 1:2); saved_exo = oo_.exo_simul(1:2, :); oo_.endo_simul = oo_.endo_simul(:, 3:end); oo_.exo_simul = oo_.exo_simul(3:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; @@ -90,7 +90,7 @@ saved_endo = oo_.endo_simul(:, 1:5); saved_exo = oo_.exo_simul(1:5, :); oo_.endo_simul = oo_.endo_simul(:, 6:end); oo_.exo_simul = oo_.exo_simul(6:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_,true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; diff --git a/tests/deterministic_simulations/pfwee_constant_sim_length.mod b/tests/deterministic_simulations/pfwee_constant_sim_length.mod index 109d047b2..a081e19d7 100644 --- a/tests/deterministic_simulations/pfwee_constant_sim_length.mod +++ b/tests/deterministic_simulations/pfwee_constant_sim_length.mod @@ -45,7 +45,7 @@ verbatim; % Information arriving in period 1 (temp shock now) oo_.exo_simul(2,1) = 1.2; -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); % Information arriving in period 2 (temp shock now + permanent shock in future) oo_.exo_simul(3,1) = 1.3; @@ -57,7 +57,7 @@ saved_endo = oo_.endo_simul(:, 1); saved_exo = oo_.exo_simul(1, :); oo_.endo_simul = oo_.endo_simul(:, 2:end); oo_.exo_simul = oo_.exo_simul(2:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; @@ -71,7 +71,7 @@ saved_endo = oo_.endo_simul(:, 1:2); saved_exo = oo_.exo_simul(1:2, :); oo_.endo_simul = oo_.endo_simul(:, 3:end); oo_.exo_simul = oo_.exo_simul(3:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; @@ -87,7 +87,7 @@ saved_endo = oo_.endo_simul(:, 1:5); saved_exo = oo_.exo_simul(1:5, :); oo_.endo_simul = oo_.endo_simul(:, 6:end); oo_.exo_simul = oo_.exo_simul(6:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; diff --git a/tests/deterministic_simulations/pfwee_learnt_in.mod b/tests/deterministic_simulations/pfwee_learnt_in.mod index b59a4af87..49b504a41 100644 --- a/tests/deterministic_simulations/pfwee_learnt_in.mod +++ b/tests/deterministic_simulations/pfwee_learnt_in.mod @@ -95,7 +95,7 @@ verbatim; % Information arriving in period 1 (temp shock now and tomorrow) oo_.exo_simul(2:3,1) = 1.2; -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); % Information arriving in period 2 (temp shock now + permanent shock in future) oo_.exo_simul(3,1) = 1.3; @@ -108,7 +108,7 @@ saved_endo = oo_.endo_simul(:, 1); saved_exo = oo_.exo_simul(1, :); oo_.endo_simul = oo_.endo_simul(:, 2:end); oo_.exo_simul = oo_.exo_simul(2:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; @@ -125,7 +125,7 @@ saved_endo = oo_.endo_simul(:, 1:2); saved_exo = oo_.exo_simul(1:2, :); oo_.endo_simul = oo_.endo_simul(:, 3:end); oo_.exo_simul = oo_.exo_simul(3:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; @@ -141,7 +141,7 @@ saved_endo = oo_.endo_simul(:, 1:5); saved_exo = oo_.exo_simul(1:5, :); oo_.endo_simul = oo_.endo_simul(:, 6:end); oo_.exo_simul = oo_.exo_simul(6:end, :); -perfect_foresight_solver(true); +oo_=perfect_foresight_solver(M_, options_, oo_, true); oo_.endo_simul = [ saved_endo oo_.endo_simul ]; oo_.exo_simul = [ saved_exo; oo_.exo_simul ]; diff --git a/tests/deterministic_simulations/purely_backward/ar1.mod b/tests/deterministic_simulations/purely_backward/ar1.mod index 024d3748d..657883e95 100644 --- a/tests/deterministic_simulations/purely_backward/ar1.mod +++ b/tests/deterministic_simulations/purely_backward/ar1.mod @@ -31,7 +31,8 @@ perfect_foresight_solver; if ~oo_.deterministic_simulation.status error('Perfect foresight simulation failed') end +send_endogenous_variables_to_workspace; -if max(abs(y-[1; exp(cumprod([1; rho*ones(9, 1)]))]))>options_.dynatol.x +if max(abs(y'-[1; exp(cumprod([1; rho*ones(9, 1)]))]))>options_.dynatol.x error('Wrong solution!') end diff --git a/tests/estimation/method_of_moments/RBC/RBC_MoM_SMM_ME.mod b/tests/estimation/method_of_moments/RBC/RBC_MoM_SMM_ME.mod index ea351a401..df00015b6 100644 --- a/tests/estimation/method_of_moments/RBC/RBC_MoM_SMM_ME.mod +++ b/tests/estimation/method_of_moments/RBC/RBC_MoM_SMM_ME.mod @@ -79,6 +79,7 @@ end; % Simulate data stoch_simul(order=@{orderApp},pruning,nodisplay,nomoments,periods=250); +send_endogenous_variables_to_workspace; save('RBC_MoM_data_@{orderApp}.mat', options_.varobs{:} ); pause(1); diff --git a/tests/estimation/method_of_moments/RBC/RBC_MoM_prefilter.mod b/tests/estimation/method_of_moments/RBC/RBC_MoM_prefilter.mod index 7bdd1aa5e..b441cb686 100644 --- a/tests/estimation/method_of_moments/RBC/RBC_MoM_prefilter.mod +++ b/tests/estimation/method_of_moments/RBC/RBC_MoM_prefilter.mod @@ -35,6 +35,7 @@ varobs n c iv; % Simulate data stoch_simul(order=@{orderApp},pruning,nodisplay,nomoments,periods=250,TeX); +send_endogenous_variables_to_workspace; save('RBC_MoM_data_@{orderApp}.mat', options_.varobs{:} ); pause(1); diff --git a/tests/kalman_filter_smoother/gen_data.mod b/tests/kalman_filter_smoother/gen_data.mod index 1c44380a0..d084d217f 100644 --- a/tests/kalman_filter_smoother/gen_data.mod +++ b/tests/kalman_filter_smoother/gen_data.mod @@ -33,6 +33,16 @@ end; stoch_simul(periods=2000,irf=0); +verbatim; +w=oo_.endo_simul(strmatch('w',M_.endo_names,'exact'),:)'; +x=oo_.endo_simul(strmatch('x',M_.endo_names,'exact'),:)'; +y=oo_.endo_simul(strmatch('y',M_.endo_names,'exact'),:)'; +z=oo_.endo_simul(strmatch('z',M_.endo_names,'exact'),:)'; +dw=oo_.endo_simul(strmatch('dw',M_.endo_names,'exact'),:)'; +dx=oo_.endo_simul(strmatch('dx',M_.endo_names,'exact'),:)'; +dy=oo_.endo_simul(strmatch('dy',M_.endo_names,'exact'),:)'; +end; + plot([w x y z]); save data_algo.mat w x y z dw dx dy; diff --git a/tests/kalman_filter_smoother/test_compute_Pinf_Pstar_data.mod b/tests/kalman_filter_smoother/test_compute_Pinf_Pstar_data.mod index e3032458d..1e596a6c4 100644 --- a/tests/kalman_filter_smoother/test_compute_Pinf_Pstar_data.mod +++ b/tests/kalman_filter_smoother/test_compute_Pinf_Pstar_data.mod @@ -85,5 +85,6 @@ shocks; end; stoch_simul(order=1,irf=20,periods=500); +send_endogenous_variables_to_workspace; save data_Pinf_Pstar.mat v1 v2 v3; diff --git a/tests/lmmcp/rbcii.mod b/tests/lmmcp/rbcii.mod index 149cea325..90b63d292 100644 --- a/tests/lmmcp/rbcii.mod +++ b/tests/lmmcp/rbcii.mod @@ -58,7 +58,7 @@ perfect_foresight_solver(lmmcp, maxit=200, no_homotopy); if ~oo_.deterministic_simulation.status error('Convergence not obtained') end - +send_endogenous_variables_to_workspace; n = 40; figure(2); diff --git a/tests/loglinear/example4_loglinear.mod b/tests/loglinear/example4_loglinear.mod index 5f283ea09..4c12ef00f 100644 --- a/tests/loglinear/example4_loglinear.mod +++ b/tests/loglinear/example4_loglinear.mod @@ -130,6 +130,7 @@ if max(max(abs(struct2array(forecasts.cond.Mean)-struct2array(conditional_foreca end stoch_simul(loglinear,order=1,periods=100000); +send_endogenous_variables_to_workspace; if abs(mean(y)-0.0776)>0.02 error('Simulations are wrong') end diff --git a/tests/moments/example1_hp_test.mod b/tests/moments/example1_hp_test.mod index 580406b64..7e17be9cb 100644 --- a/tests/moments/example1_hp_test.mod +++ b/tests/moments/example1_hp_test.mod @@ -73,15 +73,16 @@ total_var_filtered=diag(oo_.var); oo_filtered_all_shocks=oo_; stoch_simul(order=1,nofunctions,hp_filter=0,periods=2500000,nomoments); +send_endogenous_variables_to_workspace; options_.nomoments=0; oo_unfiltered_all_shocks=oo_; -[junk, y_filtered]=sample_hp_filter(y,1600); -[junk, c_filtered]=sample_hp_filter(c,1600); -[junk, k_filtered]=sample_hp_filter(k,1600); -[junk, a_filtered]=sample_hp_filter(a,1600); -[junk, h_filtered]=sample_hp_filter(h,1600); -[junk, b_filtered]=sample_hp_filter(b,1600); +[junk, y_filtered]=sample_hp_filter(y',1600); +[junk, c_filtered]=sample_hp_filter(c',1600); +[junk, k_filtered]=sample_hp_filter(k',1600); +[junk, a_filtered]=sample_hp_filter(a',1600); +[junk, h_filtered]=sample_hp_filter(h',1600); +[junk, b_filtered]=sample_hp_filter(b',1600); verbatim; total_std_all_shocks_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered]); @@ -108,14 +109,15 @@ total_var_filtered_one_shock=diag(oo_.var); oo_filtered_one_shock=oo_; stoch_simul(order=1,nofunctions,hp_filter=0,periods=2500000,nomoments); +send_endogenous_variables_to_workspace; oo_unfiltered_one_shock=oo_; -[junk, y_filtered]=sample_hp_filter(y,1600); -[junk, c_filtered]=sample_hp_filter(c,1600); -[junk, k_filtered]=sample_hp_filter(k,1600); -[junk, a_filtered]=sample_hp_filter(a,1600); -[junk, h_filtered]=sample_hp_filter(h,1600); -[junk, b_filtered]=sample_hp_filter(b,1600); +[junk, y_filtered]=sample_hp_filter(y',1600); +[junk, c_filtered]=sample_hp_filter(c',1600); +[junk, k_filtered]=sample_hp_filter(k',1600); +[junk, a_filtered]=sample_hp_filter(a',1600); +[junk, h_filtered]=sample_hp_filter(h',1600); +[junk, b_filtered]=sample_hp_filter(b',1600); verbatim; total_std_one_shock_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered]); diff --git a/tests/moments/test_AR1_spectral_density.mod b/tests/moments/test_AR1_spectral_density.mod index 3e95fd570..4e5524652 100644 --- a/tests/moments/test_AR1_spectral_density.mod +++ b/tests/moments/test_AR1_spectral_density.mod @@ -20,6 +20,7 @@ options_.SpectralDensity.trigger=1; options_.bandpass.indicator=0; stoch_simul(order=1,nofunctions,hp_filter=0,irf=0,periods=1000000,filtered_theoretical_moments_grid=2048); +send_endogenous_variables_to_workspace; white_noise_sample=white_noise; diff --git a/tests/particle/first_spec.mod b/tests/particle/first_spec.mod index 98a1a16f8..6a1706bc5 100644 --- a/tests/particle/first_spec.mod +++ b/tests/particle/first_spec.mod @@ -12,7 +12,7 @@ var ca = 0.01^2; end; stoch_simul(order=3,periods=200, irf=0); - +send_endogenous_variables_to_workspace; save('my_data.mat','q','ca'); estimation(datafile='my_data.mat',order=2,mode_compute=0,mh_replic=0,filter_algorithm=sis,nonlinear_filter_initialization=2 diff --git a/tests/particle/first_spec_MCMC.mod b/tests/particle/first_spec_MCMC.mod index 9131f47c5..e7a00b63e 100644 --- a/tests/particle/first_spec_MCMC.mod +++ b/tests/particle/first_spec_MCMC.mod @@ -12,6 +12,7 @@ var ca = 0.01^2; end; stoch_simul(order=3,periods=200, irf=0); +send_endogenous_variables_to_workspace; save('my_data_MCMC.mat','ca','b'); diff --git a/tests/particle/first_spec_xfail_0.mod b/tests/particle/first_spec_xfail_0.mod index ceea4a812..5f44974ae 100644 --- a/tests/particle/first_spec_xfail_0.mod +++ b/tests/particle/first_spec_xfail_0.mod @@ -10,6 +10,7 @@ var nnu = 0.03^2; end; stoch_simul(order=3,periods=200, irf=0, nomoments, nofunctions); +send_endogenous_variables_to_workspace; save('my_data.mat','q','ca'); diff --git a/tests/particle/first_spec_xfail_1.mod b/tests/particle/first_spec_xfail_1.mod index 66d588f45..688c12913 100644 --- a/tests/particle/first_spec_xfail_1.mod +++ b/tests/particle/first_spec_xfail_1.mod @@ -11,6 +11,7 @@ var q = 0.01^2; end; stoch_simul(order=3,periods=200, irf=0); +send_endogenous_variables_to_workspace; save('my_data.mat','q','ca');