diff --git a/matlab/print_expectations.m b/matlab/print_expectations.m
index e32ba2d84e30e932a8e7c17250cee67971f4048e..89be53633074e74b5b660725daa98919422be7f9 100644
--- a/matlab/print_expectations.m
+++ b/matlab/print_expectations.m
@@ -299,23 +299,7 @@ for i=1:maxlag
     for j=1:length(auxmodel.list_of_variables_in_companion_var)
         id = id+1;
         variable = auxmodel.list_of_variables_in_companion_var{j};
-        transformations = {};
-        ida = get_aux_variable_id(variable);
-        op = 0;
-        while ida
-            op = op+1;
-            if isequal(M_.aux_vars(ida).type, 8)
-                transformations(op) = {'diff'};
-                variable = M_.endo_names{M_.aux_vars(ida).orig_index};
-                ida = get_aux_variable_id(variable);
-            elseif isequal(M_.aux_vars(ida).type, 10)
-                transformations(op) = {M_.aux_vars(ida).unary_op};
-                variable = M_.endo_names{M_.aux_vars(ida).orig_index};
-                ida = get_aux_variable_id(variable);
-            else
-                error('This case is not implemented.')
-            end
-        end
+        [variable, transformations] = rewrite_aux_variable(variable, M_);
         switch expectationmodelkind
           case 'var'
             parameter = M_.params(expectationmodel.param_indices(id));
@@ -378,13 +362,31 @@ if isequal(expectationmodelkind, 'pac') && growth_correction
         for iter = 1:numel(expectationmodel.growth_linear_comb)
             vgrowth='';
             if expectationmodel.growth_linear_comb(iter).exo_id > 0
-                vgrowth = strcat('dbase.', M_.exo_names{expectationmodel.growth_linear_comb(iter).exo_id});
+                variable = M_.exo_names{expectationmodel.growth_linear_comb(iter).exo_id};
             elseif expectationmodel.growth_linear_comb(iter).endo_id > 0
-                vgrowth = strcat('dbase.', M_.endo_names{expectationmodel.growth_linear_comb(iter).endo_id});
+                variable = M_.endo_names{expectationmodel.growth_linear_comb(iter).endo_id};
             end
-            if expectationmodel.growth_linear_comb(iter).lag ~= 0
-                vgrowth = sprintf('%s(%d)', vgrowth, expectationmodel.growth_linear_comb(iter).lag);
+            [variable, transformations] = rewrite_aux_variable(variable, M_);
+            if isempty(transformations)
+                if expectationmodel.growth_linear_comb(iter).lag ~= 0
+                    variable = sprintf('%s(%d)', variable, expectationmodel.growth_linear_comb(iter).lag);
+                end
+            else
+                for k=rows(transformations):-1:1
+                    if isequal(transformations{k,1}, 'lag')
+                        variable = sprintf('%s.lag(%u)', variable, -transformations{k,2});
+                    elseif isequal(transformations{k,1}, 'diff')
+                        if isempty(transformations{k,2})
+                            variable = sprintf('%s.%s()', variable, transformations{k,1});
+                        else
+                            variable = sprintf('%s(-%u).%s()', variable, transformations{k,2}, transformations{k,1});
+                        end
+                    else
+                        variable = sprintf('%s.%s()', variable, transformations{k});
+                    end
+                end
             end
+            vgrowth = strcat('dbase.', variable);
             if expectationmodel.growth_linear_comb(iter).param_id > 0
                 if ~isempty(vgrowth)
                     vgrowth = sprintf('%1.16f*%s',M_.params(expectationmodel.growth_linear_comb(iter).param_id), vgrowth);
@@ -418,14 +420,31 @@ if isequal(expectationmodelkind, 'pac') && growth_correction
                 for iter = 1:numel(expectationmodel.components(i).growth_linear_comb)
                     vgrowth='';
                     if expectationmodel.components(i).growth_linear_comb(iter).exo_id > 0
-                        vgrowth = strcat('dbase.', M_.exo_names{expectationmodel.components(i).growth_linear_comb(iter).exo_id});
+                        variable = M_.exo_names{expectationmodel.components(i).growth_linear_comb(iter).exo_id};
                     elseif expectationmodel.components(i).growth_linear_comb(iter).endo_id > 0
-                        vgrowth = strcat('dbase.', M_.endo_names{expectationmodel.components(i).growth_linear_comb(iter).endo_id});
-                        % TODO Check if we should not substitute auxiliary variables with original transformed variables here.
+                        variable = M_.endo_names{expectationmodel.components(i).growth_linear_comb(iter).endo_id};
                     end
-                    if expectationmodel.components(i).growth_linear_comb(iter).lag ~= 0
-                        vgrowth = sprintf('%s(%d)', vgrowth, expectationmodel.components(i).growth_linear_comb(iter).lag);
+                    [variable, transformations] = rewrite_aux_variable(variable, M_);
+                    if isempty(transformations)
+                        if expectationmodel.components(i).growth_linear_comb(iter).lag ~= 0
+                            variable = sprintf('%s(%d)', variable, expectationmodel.components(i).growth_linear_comb(iter).lag);
+                        end
+                    else
+                        for k=rows(transformations):-1:1
+                            if isequal(transformations{k,1}, 'lag')
+                                variable = sprintf('%s.lag(%u)', variable, -transformations{k,2});
+                            elseif isequal(transformations{k,1}, 'diff')
+                                if isempty(transformations{k,2})
+                                    variable = sprintf('%s.%s()', variable, transformations{k,1});
+                                else
+                                    variable = sprintf('%s(-%u).%s()', variable, transformations{k,2}, transformations{k,1});
+                                end
+                            else
+                                variable = sprintf('%s.%s()', variable, transformations{k});
+                            end
+                        end
                     end
+                    vgrowth = strcat('dbase.', variable);
                     if expectationmodel.components(i).growth_linear_comb(iter).param_id > 0
                         if ~isempty(vgrowth)
                             vgrowth = sprintf('%1.16f*%s',M_.params(expectationmodel.components(i).growth_linear_comb(iter).param_id), vgrowth);
diff --git a/matlab/rewrite_aux_variable.m b/matlab/rewrite_aux_variable.m
new file mode 100644
index 0000000000000000000000000000000000000000..f49bd11838d7b41d5e58bffc20e9471d6f298822
--- /dev/null
+++ b/matlab/rewrite_aux_variable.m
@@ -0,0 +1,47 @@
+function [variable, transformations] = rewrite_aux_variable(variable, M_)
+
+% Copyright © 2021 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/>.
+
+transformations = {};
+ida = get_aux_variable_id(variable);
+op = 0;
+dl = 0;
+
+while ida
+    op = op+1;
+    if isequal(M_.aux_vars(ida).type, 1)
+        transformations(op,1) = {'lag'};
+        transformations(op,2) = {M_.aux_vars(ida).orig_lead_lag-1};
+        variable = M_.endo_names{M_.aux_vars(ida).orig_index};
+    elseif isequal(M_.aux_vars(ida).type, 8)
+        transformations(op, 1) = {'diff'};
+        variable = M_.endo_names{M_.aux_vars(ida).orig_index};
+    elseif isequal(M_.aux_vars(ida).type, 9)
+        dl = dl+1;
+        transformations(op, 1) = {'lag'};
+        transformations(op, 2) = {dl};
+        op = op-1;
+        variable = M_.endo_names{M_.aux_vars(ida).orig_index};
+    elseif isequal(M_.aux_vars(ida).type, 10)
+        transformations(op, 1) = {M_.aux_vars(ida).unary_op};
+        variable = M_.endo_names{M_.aux_vars(ida).orig_index};
+    else
+        error('This case is not implemented.')
+    end
+    ida = get_aux_variable_id(variable);
+end
\ No newline at end of file
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 783cb4c906ddea122fc6d3f64df81bc7ba5e60de..8d007ff13754f973f53ddc1b708030703894d5fb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -529,6 +529,10 @@ ECB_MODFILES = \
 	pac/var-10e/example1.mod \
 	pac/var-10e/example2.mod \
 	pac/var-11e/example1.mod \
+	pac/var-12/example1.mod \
+	pac/var-12/example2.mod \
+	pac/var-12/example11.mod \
+	pac/var-12/example12.mod \
 	pac/trend-component-1/example1.mod \
 	pac/trend-component-2/example1.mod \
 	pac/trend-component-3/example1.mod \
diff --git a/tests/pac/var-12/example1.mod b/tests/pac/var-12/example1.mod
new file mode 100644
index 0000000000000000000000000000000000000000..0cb734f268d69ba26c1eb3a511ecc3ec5124f716
--- /dev/null
+++ b/tests/pac/var-12/example1.mod
@@ -0,0 +1,74 @@
+// --+ options: json=compute, stochastic +--
+
+var y x z v;
+
+varexo ex ey ez ;
+
+parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
+
+parameters beta e_c_m c_z_1 c_z_2;               // PAC equation parameters
+
+a_y_1 =  .2;
+a_y_2 =  .3;
+b_y_1 =  .1;
+b_y_2 =  .4;
+b_x_1 = -.1;
+b_x_2 = -.2;
+d_y = .5;
+
+
+beta  =  .9;
+e_c_m =  .1;
+c_z_1 =  .7;
+c_z_2 = -.3;
+
+var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
+
+pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
+
+pac_target_info(pacman);
+  target v;
+  auxname_target_nonstationary vns;
+
+  component y;
+  auxname pv_y_;
+  kind ll;
+
+  component x;
+  growth diff(x(-2));
+  auxname pv_dx_;
+  kind dd;
+
+end;
+
+model;
+
+  [name='eq:y']
+  y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
+
+
+  [name='eq:x']
+  diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
+
+  [name='eq:v']
+  v = x + d_y*y ;
+
+  [name='eq:pac']
+  diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1))  + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
+
+end;
+
+shocks;
+  var ex = 1.0;
+  var ey = 1.0;
+  var ez = 1.0;
+end;
+
+// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
+pac.initialize('pacman');
+
+// Update the parameters of the PAC expectation model (h0 and h1 vectors).
+pac.update.expectation('pacman');
+
+// Print expanded PAC_EXPECTATION term.
+pac.print('pacman', 'eq:pac');
diff --git a/tests/pac/var-12/example1/model/pac-expectations/pacman-expression.inc b/tests/pac/var-12/example1/model/pac-expectations/pacman-expression.inc
new file mode 100644
index 0000000000000000000000000000000000000000..989a0b1c4c7e20a6efa587cb344b5dc2a6b6d91f
--- /dev/null
+++ b/tests/pac/var-12/example1/model/pac-expectations/pacman-expression.inc
@@ -0,0 +1,5 @@
+// This file has been generated by dynare (14-Jan-2022 17:56:36).
+d_y*h_pacman_component1_constant+h_pacman_component2_constant + (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_1+h_pacman_component2_var_AUX_DIFF_11_lag_1)*diff(x(-1))
+ + (d_y*h_pacman_component1_var_y_lag_1+h_pacman_component2_var_y_lag_1)*y(-1)
+ + (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_2+h_pacman_component2_var_AUX_DIFF_11_lag_2)*diff(x(-2))
+ + (d_y*h_pacman_component1_var_y_lag_2+h_pacman_component2_var_y_lag_2)*y(-2)
diff --git a/tests/pac/var-12/example1/model/pac-expectations/pacman-growth-neutrality-correction.inc b/tests/pac/var-12/example1/model/pac-expectations/pacman-growth-neutrality-correction.inc
new file mode 100644
index 0000000000000000000000000000000000000000..a84abb44e8587caff3cafd07d6da1b6d00656956
--- /dev/null
+++ b/tests/pac/var-12/example1/model/pac-expectations/pacman-growth-neutrality-correction.inc
@@ -0,0 +1,2 @@
+// This file has been generated by dynare (14-Jan-2022 17:56:36).
+pacman_component2_pac_growth_neutrality_correction*diff(x(-2))
\ No newline at end of file
diff --git a/tests/pac/var-12/example1/model/pac-expectations/pacman-parameters.inc b/tests/pac/var-12/example1/model/pac-expectations/pacman-parameters.inc
new file mode 100644
index 0000000000000000000000000000000000000000..3b1d443386683ac48911e45a2d2abb6ca95cb51e
--- /dev/null
+++ b/tests/pac/var-12/example1/model/pac-expectations/pacman-parameters.inc
@@ -0,0 +1,18 @@
+// This file has been generated by dynare (14-Jan-2022 17:56:36).
+
+parameters h_pacman_component1_constant h_pacman_component1_var_AUX_DIFF_11_lag_1 h_pacman_component1_var_y_lag_1 h_pacman_component1_var_AUX_DIFF_11_lag_2 h_pacman_component1_var_y_lag_2 h_pacman_component2_constant h_pacman_component2_var_AUX_DIFF_11_lag_1 h_pacman_component2_var_y_lag_1 h_pacman_component2_var_AUX_DIFF_11_lag_2 h_pacman_component2_var_y_lag_2;
+
+h_pacman_component1_constant = 0.0000000000000000;
+h_pacman_component1_var_AUX_DIFF_11_lag_1 = 0.0145990564819670;
+h_pacman_component1_var_y_lag_1 = 0.0060141756634789;
+h_pacman_component1_var_AUX_DIFF_11_lag_2 = 0.0088556033620678;
+h_pacman_component1_var_y_lag_2 = 0.0007072909429702;
+h_pacman_component2_constant = 0.0000000000000000;
+h_pacman_component2_var_AUX_DIFF_11_lag_1 = -0.0204386323060280;
+h_pacman_component2_var_y_lag_1 = -0.0090103235508248;
+h_pacman_component2_var_AUX_DIFF_11_lag_2 = -0.0026679701308692;
+h_pacman_component2_var_y_lag_2 = -0.0089540800364464;
+
+parameters pacman_component2_pac_growth_neutrality_correction;
+
+pacman_component2_pac_growth_neutrality_correction = 0.1853271645736974;
diff --git a/tests/pac/var-12/example11.mod b/tests/pac/var-12/example11.mod
new file mode 100644
index 0000000000000000000000000000000000000000..68f3a88f3ab11608095719ca828c813dd0895585
--- /dev/null
+++ b/tests/pac/var-12/example11.mod
@@ -0,0 +1,55 @@
+// --+ options: json=compute, stochastic +--
+
+var y x z;
+
+varexo ex ey ez ;
+
+parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
+
+parameters beta e_c_m c_z_1 c_z_2;               // PAC equation parameters
+
+a_y_1 =  .2;
+a_y_2 =  .3;
+b_y_1 =  .1;
+b_y_2 =  .4;
+b_x_1 = -.1;
+b_x_2 = -.2;
+d_y = .5;
+
+beta  =  .9;
+e_c_m =  .1;
+c_z_1 =  .7;
+c_z_2 = -.3;
+
+var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
+
+pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman, growth=diff(x(-2)));
+
+model;
+
+  [name='eq:y']
+  y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
+
+
+  [name='eq:x']
+  diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
+
+  [name='eq:pac']
+  diff(z) = e_c_m*(x(-1)-z(-1)) + c_z_1*diff(z(-1))  + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
+
+end;
+
+shocks;
+  var ex = 1.0;
+  var ey = 1.0;
+  var ez = 1.0;
+end;
+
+// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
+pac.initialize('pacman');
+
+// Update the parameters of the PAC expectation model (h0 and h1 vectors).
+pac.update.expectation('pacman');
+
+// Print expanded PAC_EXPECTATION term.
+pac.print('pacman', 'eq:pac');
diff --git a/tests/pac/var-12/example11/model/pac-expectations/pacman-expression.inc b/tests/pac/var-12/example11/model/pac-expectations/pacman-expression.inc
new file mode 100644
index 0000000000000000000000000000000000000000..cb20354087e00ecf2b436799ea3005a9f4a990a6
--- /dev/null
+++ b/tests/pac/var-12/example11/model/pac-expectations/pacman-expression.inc
@@ -0,0 +1,5 @@
+// This file has been generated by dynare (14-Jan-2022 19:06:42).
+h_pacman_constant + h_pacman_var_AUX_DIFF_31_lag_1*diff(x(-1))
+ + h_pacman_var_y_lag_1*y(-1)
+ + h_pacman_var_AUX_DIFF_31_lag_2*diff(x(-2))
+ + h_pacman_var_y_lag_2*y(-2)
diff --git a/tests/pac/var-12/example11/model/pac-expectations/pacman-growth-neutrality-correction.inc b/tests/pac/var-12/example11/model/pac-expectations/pacman-growth-neutrality-correction.inc
new file mode 100644
index 0000000000000000000000000000000000000000..fadba9b2965753ad9e3301f52fc0e4c1ca2d4eac
--- /dev/null
+++ b/tests/pac/var-12/example11/model/pac-expectations/pacman-growth-neutrality-correction.inc
@@ -0,0 +1,2 @@
+// This file has been generated by dynare (14-Jan-2022 19:06:42).
+pacman_pac_growth_neutrality_correction*diff(x(-2))
\ No newline at end of file
diff --git a/tests/pac/var-12/example11/model/pac-expectations/pacman-parameters.inc b/tests/pac/var-12/example11/model/pac-expectations/pacman-parameters.inc
new file mode 100644
index 0000000000000000000000000000000000000000..ce7144a0b24b766546e6a9260fdb5ab43e420d89
--- /dev/null
+++ b/tests/pac/var-12/example11/model/pac-expectations/pacman-parameters.inc
@@ -0,0 +1,13 @@
+// This file has been generated by dynare (14-Jan-2022 19:06:42).
+
+parameters h_pacman_constant h_pacman_var_AUX_DIFF_31_lag_1 h_pacman_var_y_lag_1 h_pacman_var_AUX_DIFF_31_lag_2 h_pacman_var_y_lag_2;
+
+h_pacman_constant = 0.0000000000000000;
+h_pacman_var_AUX_DIFF_31_lag_1 = -0.0204386323060280;
+h_pacman_var_y_lag_1 = -0.0090103235508248;
+h_pacman_var_AUX_DIFF_31_lag_2 = -0.0026679701308692;
+h_pacman_var_y_lag_2 = -0.0089540800364464;
+
+parameters pacman_pac_growth_neutrality_correction;
+
+pacman_pac_growth_neutrality_correction = 0.1853271645736974;
diff --git a/tests/pac/var-12/example12.mod b/tests/pac/var-12/example12.mod
new file mode 100644
index 0000000000000000000000000000000000000000..9685ef6ee6a1d1c2ca21dd7c4071bade9a52facc
--- /dev/null
+++ b/tests/pac/var-12/example12.mod
@@ -0,0 +1,56 @@
+// --+ options: json=compute, stochastic +--
+
+var y x z;
+
+varexo ex ey ez ;
+
+parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
+
+parameters beta e_c_m c_z_1 c_z_2;               // PAC equation parameters
+
+a_y_1 =  .2;
+a_y_2 =  .3;
+b_y_1 =  .1;
+b_y_2 =  .4;
+b_x_1 = -.1;
+b_x_2 = -.2;
+d_y = .5;
+
+
+beta  =  .9;
+e_c_m =  .1;
+c_z_1 =  .7;
+c_z_2 = -.3;
+
+var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
+
+pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman, growth=x(-2));
+
+model;
+
+  [name='eq:y']
+  y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
+
+
+  [name='eq:x']
+  diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
+
+  [name='eq:pac']
+  diff(z) = e_c_m*(x(-1)-z(-1)) + c_z_1*diff(z(-1))  + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
+
+end;
+
+shocks;
+  var ex = 1.0;
+  var ey = 1.0;
+  var ez = 1.0;
+end;
+
+// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
+pac.initialize('pacman');
+
+// Update the parameters of the PAC expectation model (h0 and h1 vectors).
+pac.update.expectation('pacman');
+
+// Print expanded PAC_EXPECTATION term.
+pac.print('pacman', 'eq:pac');
diff --git a/tests/pac/var-12/example12/model/pac-expectations/pacman-expression.inc b/tests/pac/var-12/example12/model/pac-expectations/pacman-expression.inc
new file mode 100644
index 0000000000000000000000000000000000000000..6cf6c9953e3b444d44b3824567e51f41d42ca532
--- /dev/null
+++ b/tests/pac/var-12/example12/model/pac-expectations/pacman-expression.inc
@@ -0,0 +1,5 @@
+// This file has been generated by dynare (14-Jan-2022 19:11:08).
+h_pacman_constant + h_pacman_var_AUX_DIFF_31_lag_1*diff(x(-1))
+ + h_pacman_var_y_lag_1*y(-1)
+ + h_pacman_var_AUX_DIFF_31_lag_2*diff(x(-2))
+ + h_pacman_var_y_lag_2*y(-2)
diff --git a/tests/pac/var-12/example12/model/pac-expectations/pacman-growth-neutrality-correction.inc b/tests/pac/var-12/example12/model/pac-expectations/pacman-growth-neutrality-correction.inc
new file mode 100644
index 0000000000000000000000000000000000000000..a075d904505f5ed5227564a83c42f5c9305b0acf
--- /dev/null
+++ b/tests/pac/var-12/example12/model/pac-expectations/pacman-growth-neutrality-correction.inc
@@ -0,0 +1,2 @@
+// This file has been generated by dynare (14-Jan-2022 19:11:08).
+pacman_pac_growth_neutrality_correction*x(-2)
\ No newline at end of file
diff --git a/tests/pac/var-12/example12/model/pac-expectations/pacman-parameters.inc b/tests/pac/var-12/example12/model/pac-expectations/pacman-parameters.inc
new file mode 100644
index 0000000000000000000000000000000000000000..9e0f5c4f50e67b35c92f8f5f0fa2643bf30e8a2c
--- /dev/null
+++ b/tests/pac/var-12/example12/model/pac-expectations/pacman-parameters.inc
@@ -0,0 +1,13 @@
+// This file has been generated by dynare (14-Jan-2022 19:11:08).
+
+parameters h_pacman_constant h_pacman_var_AUX_DIFF_31_lag_1 h_pacman_var_y_lag_1 h_pacman_var_AUX_DIFF_31_lag_2 h_pacman_var_y_lag_2;
+
+h_pacman_constant = 0.0000000000000000;
+h_pacman_var_AUX_DIFF_31_lag_1 = -0.0204386323060280;
+h_pacman_var_y_lag_1 = -0.0090103235508248;
+h_pacman_var_AUX_DIFF_31_lag_2 = -0.0026679701308692;
+h_pacman_var_y_lag_2 = -0.0089540800364464;
+
+parameters pacman_pac_growth_neutrality_correction;
+
+pacman_pac_growth_neutrality_correction = 0.1853271645736974;
diff --git a/tests/pac/var-12/example13.mod b/tests/pac/var-12/example13.mod
new file mode 100644
index 0000000000000000000000000000000000000000..ff888b85258f96d195290cdf10550c4f68144b87
--- /dev/null
+++ b/tests/pac/var-12/example13.mod
@@ -0,0 +1,55 @@
+// --+ options: json=compute, stochastic +--
+
+var y x z;
+
+varexo ex ey ez ;
+
+parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
+
+parameters beta e_c_m c_z_1 c_z_2;               // PAC equation parameters
+
+a_y_1 =  .2;
+a_y_2 =  .3;
+b_y_1 =  .1;
+b_y_2 =  .4;
+b_x_1 = -.1;
+b_x_2 = -.2;
+d_y = .5;
+
+beta  =  .9;
+e_c_m =  .1;
+c_z_1 =  .7;
+c_z_2 = -.3;
+
+var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
+
+pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman, growth=diff(log(x(-2))));
+
+model;
+
+  [name='eq:y']
+  y = a_y_1*y(-1) + a_y_2*diff(log(x(-1))) + b_y_1*y(-2) + b_y_2*diff(log(x(-2))) + ey ;
+
+
+  [name='eq:x']
+  diff(log(x)) = b_x_1*y(-2) + b_x_2*diff(log(x(-1))) + ex ;
+
+  [name='eq:pac']
+  diff(log(z)) = e_c_m*(log(x(-1))-log(z(-1))) + c_z_1*diff(log(z(-1)))  + c_z_2*diff(log(z(-2))) + pac_expectation(pacman) + ez;
+
+end;
+
+shocks;
+  var ex = 1.0;
+  var ey = 1.0;
+  var ez = 1.0;
+end;
+
+// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
+pac.initialize('pacman');
+
+// Update the parameters of the PAC expectation model (h0 and h1 vectors).
+pac.update.expectation('pacman');
+
+// Print expanded PAC_EXPECTATION term.
+pac.print('pacman', 'eq:pac');
diff --git a/tests/pac/var-12/example2.mod b/tests/pac/var-12/example2.mod
new file mode 100644
index 0000000000000000000000000000000000000000..b1cdee083827c4bdcfa3c3abae2b25405664a5df
--- /dev/null
+++ b/tests/pac/var-12/example2.mod
@@ -0,0 +1,74 @@
+// --+ options: json=compute, stochastic +--
+
+var y x z v;
+
+varexo ex ey ez ;
+
+parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
+
+parameters beta e_c_m c_z_1 c_z_2;               // PAC equation parameters
+
+a_y_1 =  .2;
+a_y_2 =  .3;
+b_y_1 =  .1;
+b_y_2 =  .4;
+b_x_1 = -.1;
+b_x_2 = -.2;
+d_y = .5;
+
+
+beta  =  .9;
+e_c_m =  .1;
+c_z_1 =  .7;
+c_z_2 = -.3;
+
+var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
+
+pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
+
+pac_target_info(pacman);
+  target v;
+  auxname_target_nonstationary vns;
+
+  component y;
+  auxname pv_y_;
+  kind ll;
+
+  component x;
+  growth x(-2);
+  auxname pv_dx_;
+  kind dd;
+
+end;
+
+model;
+
+  [name='eq:y']
+  y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
+
+
+  [name='eq:x']
+  diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
+
+  [name='eq:v']
+  v = x + d_y*y ;
+
+  [name='eq:pac']
+  diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1))  + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
+
+end;
+
+shocks;
+  var ex = 1.0;
+  var ey = 1.0;
+  var ez = 1.0;
+end;
+
+// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
+pac.initialize('pacman');
+
+// Update the parameters of the PAC expectation model (h0 and h1 vectors).
+pac.update.expectation('pacman');
+
+// Print expanded PAC_EXPECTATION term.
+pac.print('pacman', 'eq:pac');
diff --git a/tests/pac/var-12/example2/model/pac-expectations/pacman-expression.inc b/tests/pac/var-12/example2/model/pac-expectations/pacman-expression.inc
new file mode 100644
index 0000000000000000000000000000000000000000..cddbaf4966bec89a3625c85ffa454f4a520081b9
--- /dev/null
+++ b/tests/pac/var-12/example2/model/pac-expectations/pacman-expression.inc
@@ -0,0 +1,5 @@
+// This file has been generated by dynare (14-Jan-2022 17:58:52).
+d_y*h_pacman_component1_constant+h_pacman_component2_constant + (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_1+h_pacman_component2_var_AUX_DIFF_11_lag_1)*diff(x(-1))
+ + (d_y*h_pacman_component1_var_y_lag_1+h_pacman_component2_var_y_lag_1)*y(-1)
+ + (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_2+h_pacman_component2_var_AUX_DIFF_11_lag_2)*diff(x(-2))
+ + (d_y*h_pacman_component1_var_y_lag_2+h_pacman_component2_var_y_lag_2)*y(-2)
diff --git a/tests/pac/var-12/example2/model/pac-expectations/pacman-growth-neutrality-correction.inc b/tests/pac/var-12/example2/model/pac-expectations/pacman-growth-neutrality-correction.inc
new file mode 100644
index 0000000000000000000000000000000000000000..07d37629bffafec00d227d63224a13826ed680d5
--- /dev/null
+++ b/tests/pac/var-12/example2/model/pac-expectations/pacman-growth-neutrality-correction.inc
@@ -0,0 +1,2 @@
+// This file has been generated by dynare (14-Jan-2022 17:58:52).
+pacman_component2_pac_growth_neutrality_correction*x(-2)
\ No newline at end of file
diff --git a/tests/pac/var-12/example2/model/pac-expectations/pacman-parameters.inc b/tests/pac/var-12/example2/model/pac-expectations/pacman-parameters.inc
new file mode 100644
index 0000000000000000000000000000000000000000..b7fd582486f9cd3ff4800693972be4a71fcbf828
--- /dev/null
+++ b/tests/pac/var-12/example2/model/pac-expectations/pacman-parameters.inc
@@ -0,0 +1,18 @@
+// This file has been generated by dynare (14-Jan-2022 17:58:52).
+
+parameters h_pacman_component1_constant h_pacman_component1_var_AUX_DIFF_11_lag_1 h_pacman_component1_var_y_lag_1 h_pacman_component1_var_AUX_DIFF_11_lag_2 h_pacman_component1_var_y_lag_2 h_pacman_component2_constant h_pacman_component2_var_AUX_DIFF_11_lag_1 h_pacman_component2_var_y_lag_1 h_pacman_component2_var_AUX_DIFF_11_lag_2 h_pacman_component2_var_y_lag_2;
+
+h_pacman_component1_constant = 0.0000000000000000;
+h_pacman_component1_var_AUX_DIFF_11_lag_1 = 0.0145990564819670;
+h_pacman_component1_var_y_lag_1 = 0.0060141756634789;
+h_pacman_component1_var_AUX_DIFF_11_lag_2 = 0.0088556033620678;
+h_pacman_component1_var_y_lag_2 = 0.0007072909429702;
+h_pacman_component2_constant = 0.0000000000000000;
+h_pacman_component2_var_AUX_DIFF_11_lag_1 = -0.0204386323060280;
+h_pacman_component2_var_y_lag_1 = -0.0090103235508248;
+h_pacman_component2_var_AUX_DIFF_11_lag_2 = -0.0026679701308692;
+h_pacman_component2_var_y_lag_2 = -0.0089540800364464;
+
+parameters pacman_component2_pac_growth_neutrality_correction;
+
+pacman_component2_pac_growth_neutrality_correction = 0.1853271645736974;
diff --git a/tests/pac/var-12/example3.mod b/tests/pac/var-12/example3.mod
new file mode 100644
index 0000000000000000000000000000000000000000..86e47683a9671fbd4d360d54f63de327b901bb15
--- /dev/null
+++ b/tests/pac/var-12/example3.mod
@@ -0,0 +1,68 @@
+// --+ options: json=compute, stochastic +--
+
+var y x z v;
+
+varexo ex ey ez ;
+
+parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
+
+parameters beta e_c_m c_z_1 c_z_2;               // PAC equation parameters
+
+a_y_1 =  .2;
+a_y_2 =  .3;
+b_y_1 =  .1;
+b_y_2 =  .4;
+b_x_1 = -.1;
+b_x_2 = -.2;
+d_y = .5;
+
+
+beta  =  .9;
+e_c_m =  .1;
+c_z_1 =  .7;
+c_z_2 = -.3;
+
+var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
+
+pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
+
+pac_target_info(pacman);
+  target v;
+  auxname_target_nonstationary vns;
+
+  component y;
+  auxname pv_y_;
+  kind ll;
+
+  component log(x);
+  growth diff(log(x(-2)));
+  auxname pv_dx_;
+  kind dd;
+
+end;
+
+model;
+
+  [name='eq:y']
+  y = a_y_1*y(-1) + a_y_2*diff(log(x(-1))) + b_y_1*y(-2) + b_y_2*diff(log(x(-2))) + ey ;
+
+
+  [name='eq:x']
+  diff(log(x)) = b_x_1*y(-2) + b_x_2*diff(log(x(-1))) + ex ;
+
+  [name='eq:v']
+  v = log(x) + d_y*y ;
+
+  [name='eq:pac']
+  diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1))  + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
+
+end;
+
+// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
+pac.initialize('pacman');
+
+// Update the parameters of the PAC expectation model (h0 and h1 vectors).
+pac.update.expectation('pacman');
+
+// Print expanded PAC_EXPECTATION term.
+pac.print('pacman', 'eq:pac');