From 9f9f4a99baafe9d8ce8300205313f5cc73f4aa93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Argos=29?=
 <stepan@adjemian.eu>
Date: Mon, 29 Jan 2024 14:02:15 +0100
Subject: [PATCH] =?UTF-8?q?Throw=20an=20error=20if=20composite=20PAC=20tar?=
 =?UTF-8?q?get=20=E2=88=A7=20trend=5Fcomponent=20aux.=20model.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 matlab/+pac/+update/parameters.m | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/matlab/+pac/+update/parameters.m b/matlab/+pac/+update/parameters.m
index 33b5eef37d..655ab97e4a 100644
--- a/matlab/+pac/+update/parameters.m
+++ b/matlab/+pac/+update/parameters.m
@@ -13,7 +13,7 @@ function M_ = parameters(pacname, M_, oo_, verbose)
 % SPECIAL REQUIREMENTS
 %    none
 
-% Copyright © 2018-2023 Dynare Team
+% Copyright © 2018-2024 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -78,6 +78,11 @@ else
     numberofcomponents = 0;
 end
 
+% Makes no sense to have a composite PAC target with a trend component auxiliary model (where all the variables are non stationnary)
+if numberofcomponents>0 && strcmp(M_.pac.pacman.auxiliary_model_type, 'trend_component')
+    error('Composite PAC target not allowed with trend component model.')
+end
+
 % Build the vector of PAC parameters (ECM parameter + autoregressive parameters).
 pacvalues = M_.params([pacmodel.ec.params; pacmodel.ar.params(1:pacmodel.max_lag)']);
 
@@ -90,7 +95,7 @@ if numberofcomponents
             % Find the auxiliary variables if any
             ad = find(cell2mat(cellfun(@(x) isauxiliary(x, [8 10]), varmodel.list_of_variables_in_companion_var, 'UniformOutput', false)));
             if isempty(ad)
-                error('Cannot find the trend variable in the Companion VAR/VECM model.')
+                error('Cannot find the trend variable in the Companion VAR model.')
             else
                 for j=1:length(ad)
                     auxinfo = M_.aux_vars(get_aux_variable_id(varmodel.list_of_variables_in_companion_var{ad(j)}));
@@ -105,7 +110,7 @@ if numberofcomponents
                 end
             end
             if isempty(id{i})
-                error('Cannot find the trend variable in the Companion VAR/VECM model.')
+                error('Cannot find the trend variable in the Companion VAR model.')
             end
         end
     end
@@ -115,7 +120,7 @@ else
         % Find the auxiliary variables if any
         ad = find(cell2mat(cellfun(@(x) isauxiliary(x, [8 10]), varmodel.list_of_variables_in_companion_var, 'UniformOutput', false)));
         if isempty(ad)
-            error('Cannot find the trend variable in the Companion VAR/VECM model.')
+            error('Cannot find the trend variable in the auxiliary VAR / Trend component model.')
         else
             for i=1:length(ad)
                 auxinfo = M_.aux_vars(get_aux_variable_id(varmodel.list_of_variables_in_companion_var{ad(i)}));
@@ -130,7 +135,7 @@ else
             end
         end
         if isempty(id{1})
-            error('Cannot find the trend variable in the Companion VAR/VECM model.')
+            error('Cannot find the trend variable in the auxiliary VAR / Trend component model.')
         end
     end
 end
-- 
GitLab