diff --git a/doc/dynare.texi b/doc/dynare.texi index 72d8758a19d1dd957edf71fec262658603bdd2e4..61cd82db7b6557a51aed628147c8c6d058acae16 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -8208,6 +8208,14 @@ variables between the first and last specified period. If an intermediate period is not specified, a value of 0 is assumed. That is, if you specify only values for periods 1 and 3, the values for period 2 will be 0. Currently, it is not possible to have uncontrolled intermediate periods. + +It is however possible to +have different number of controlled periods for different variables. In that +case, the order of declaration of endogenenous controlled variables and of +controlled_varexo matters: if the second endogenous variable is controlled for +less periods than the first one, the second controlled_varexo isn't set for +the last periods. + In case of the presence of @code{observation_trends}, the specified controlled path for these variables needs to include the trend component. When using the @ref{loglinear} option, it is necessary to specify the logarithm of the controlled variables. diff --git a/matlab/mcforecast3.m b/matlab/mcforecast3.m index b318d46f4b144c16a5111ef96d9f4a3f6f32261b..31215e434253b62305efd4eda82f7e0137e97601 100644 --- a/matlab/mcforecast3.m +++ b/matlab/mcforecast3.m @@ -27,6 +27,10 @@ function [forcs, e]= mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu) % This is then solved to get: % shocks_controlled_t=(y_t(controlled_vars_index)-(T*y_{t-1}(controlled_vars_index)+R(controlled_vars_index,uncontrolled_shocks_index)*shocks_uncontrolled_t)/R(controlled_vars_index,controlled_shocks_index) % +% Variable number of controlled vars are allowed in different +% periods. Missing control information are indicated by NaN in +% y_t(controlled_vars_index). +% % After obtaining the shocks, and for uncontrolled periods, the state-space representation % y_t=T*y_{t-1}+R*shocks(:,t) % is used for forecasting @@ -51,8 +55,10 @@ function [forcs, e]= mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu) if cL e = zeros(size(mcValue,1),cL); for t = 1:cL - e(:,t) = inv(mv*R*mu)*(mcValue(:,t)-mv*T*forcs(:,t)-mv*R*shocks(:,t)); - forcs(:,t+1) = T*forcs(:,t)+R*(mu*e(:,t)+shocks(:,t)); + % missing conditional values are indicated by NaN + k = find(isfinite(mcValue(:,t))); + e(k,t) = inv(mv(k,:)*R*mu(:,k))*(mcValue(k,t)-mv(k,:)*T*forcs(:,t)-mv(k,:)*R*shocks(:,t)); + forcs(:,t+1) = T*forcs(:,t)+R*(mu(:,k)*e(k,t)+shocks(:,t)); end end for t = cL+1:H diff --git a/preprocessor b/preprocessor index fbeae9619ab9603410a11a11af92a7dfeea0af81..680fb72d0dcb15ea4831fc9dd71acb04661d9519 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit fbeae9619ab9603410a11a11af92a7dfeea0af81 +Subproject commit 680fb72d0dcb15ea4831fc9dd71acb04661d9519