COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jcsantanac » Thu Sep 08, 2016 12:03 am

Prof. Pfeiffer,

I'm working on a basic Neokeynesian model of an open economy in the similar way that Gali(2008, ch 7) with some little differences. i wrote the model in the nonlinear form but i have a collinearity problem with two variables: "im" (imports) and "nx" (net exports). I have tried to fix the problem (adding and removing variables or equations) but i could not fix it.

I appreciate any suggestion to fix this problem (maybe i am writing some equations wrong). I append the ".mod" file, Thanks a lot!.

Output: (How do you read this output among the columns related?)

>> model_diagnostics(M_, options_, oo_)
model_diagnostic: the Jacobian of the static model is singular
there is 1 colinear relationships between the variables and the equations
Colinear variables:
im
nx
Colinear equations
Columns 1 through 15

1 5 6 7 11 12 14 15 16 17 18 19 20 21 23

Columns 16 through 19

24 26 27 28
Attachments
NKOE_model.mod
(5.87 KiB) Downloaded 67 times
jcsantanac
 
Posts: 16
Joined: Fri Jan 03, 2014 2:08 am

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jpfeifer » Fri Sep 09, 2016 2:35 pm

You have
Code: Select all
nx = ex - im;

But this is the only equation where nx and im appear. There is no way of disentangling the two
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jcsantanac » Wed Sep 21, 2016 2:49 pm

Thanks Prof. Pfeifer, I have solved the problem but I have other question over a dsgevar model that I was working some weeks ago and it was running ok but now there is an error with the dimension of the autocovariances matrix (could be a nonstationarity problem? however I did a stoch_simul and the problem persists). I Attached the .mod and .m file (It is a open economy model in log-linear form). Any advice will be welcome! Thanks a lot.

I am working with dynare 4.4.3 over matlab 2012b x32bits and i get the following error


Error in th_autocovariances (line 101)
ghu1(i0,:) = ghu(ikx,:);

Error in dsge_simulated_theoretical_covariance (line 103)
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);

Error in posterior_analysis>job (line 54)
[nvar,vartan,NumberOfFiles] = ...

Error in posterior_analysis (line 32)
oo_ = job(type,SampleSize,arg1,arg2,arg3,options_,M_,oo_);

Error in compute_moments_varendo (line 68)
oo_ =
posterior_analysis('variance',var_list_(i,:),var_list_(j,:),[],options_,M_,oo_);

Error in dynare_estimation_1 (line 818)
oo_ = compute_moments_varendo('posterior',options_,M_,oo_,var_list_);

Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);

Error in dsgevar_ex (line 446)
dynare_estimation(var_list_);

Error in dynare (line 180)
evalin('base',fname) ;


jpfeifer wrote:You have
Code: Select all
nx = ex - im;

But this is the only equation where nx and im appear. There is no way of disentangling the two
Attachments
DATABmr1.m
dataset
(46.97 KiB) Downloaded 47 times
modelo.mod
code
(5.32 KiB) Downloaded 47 times
jcsantanac
 
Posts: 16
Joined: Fri Jan 03, 2014 2:08 am

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jpfeifer » Wed Sep 21, 2016 5:02 pm

One problem definitely is that equation 3
Code: Select all
b = (1+ii(-1)-inflation)*b(-1)+y(-1)-c(-1)-delta*s(-1);                     

is not linear, although you use
Code: Select all
model(linear)

You might want to use the unstable version for this.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jcsantanac » Fri Sep 30, 2016 9:20 pm

Prof. Pfeifer, thanks for your comments.

I ran the code on unstable version 2019-09-29 and I got the error that you point but when i ran the code on dynare 4.4.2 version the same code works fine.

I could trust in the outputs of this version?. Why does dynare 4.4.3 not work?. I'm confused.

When I put this equation, I assumed that dynare would do a numerical linear aproximation of this kind of cross relations.

I appreciate your suggestions Professor, Thanks a lot!




>> addpath c:\dynare\4.4.2\matlab
>> dynare model.mod

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.2).
Starting preprocessing of the model file ...
Found 27 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.


EIGENVALUES:
Modulus Real Imaginary

5.63e-17 -5.63e-17 0
1.479e-16 1.479e-16 0
0.1309 0.1309 0
0.45 0.45 0
0.5 0.5 0
0.5577 0.5577 0
0.635 0.635 0
0.66 0.66 0
0.8 0.8 0
0.8 0.8 0
0.86 0.86 0
0.8729 0.8729 0
0.925 0.925 0
1.048 1.048 0
1.199 1.18 0.2123
1.199 1.18 -0.2123
Inf Inf 0
Inf Inf 0


There are 5 eigenvalue(s) larger than 1 in modulus
for 5 forward-looking variable(s)

The rank condition is verified.


STEADY-STATE RESULTS:

c 0
c_h 0
im 0
s 0
y 0
y_star 0
ii 0
i_star 0
inflation 0
inflation_star 0
n 0
w 0
b 0
a 0
v 0
nx 0
inflation_h 0
q 0
ex 0
u 0
z 0
c_obs 0
ex_obs 0
y_obs 0
inflation_obs 0
ii_obs 0
i_star_obs 0

MODEL SUMMARY

Number of variables: 27
Number of stochastic shocks: 6
Number of state variables: 13
Number of jumpers: 5
Number of static variables: 12


MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS

Variables Taylor_shock output_shock philip_shock world_output_shock inflation_star_shock is_shock
Taylor_shock 0.010000 0.000000 0.000000 0.000000 0.000000 0.000000
output_shock 0.000000 0.010000 0.000000 0.000000 0.000000 0.000000
philip_shock 0.000000 0.000000 0.010000 0.000000 0.000000 0.000000
world_output_shock 0.000000 0.000000 0.000000 0.010000 0.000000 0.000000
inflation_star_shock 0.000000 0.000000 0.000000 0.000000 0.010000 0.000000
is_shock 0.000000 0.000000 0.000000 0.000000 0.000000 0.010000

POLICY AND TRANSITION FUNCTIONS
c ex y ii inflation i_star
y(-1) 0.063245 -0.023179 0.027504 -0.027076 -0.020343 0
y_star(-1) -0.184587 -0.298652 -0.100456 0.229756 0.161542 0.225000
ii(-1) -0.181850 -0.093197 -0.229605 0.202637 -0.132442 0
i_star(-1) -0.180581 0.147995 -0.001489 0.257034 0.171480 0.500000
b(-1) 0.063245 -0.023179 0.027504 -0.027076 -0.020343 0
a(-1) 0.212607 0.085752 0.246585 -0.025622 -0.037630 0
v(-1) -0.480249 -0.228568 -0.589833 -0.074061 -0.440221 0
ex(-1) 0.020315 0.844352 0.161443 -0.041702 -0.041255 0
u(-1) -2.710324 -1.170148 -3.215960 0.580284 0.654853 0
z(-1) 1.285288 -0.207312 0.807303 0.018462 -0.054968 0
c(-1) 0.053927 0.019068 0.060020 0.036623 0.019414 0
s(-1) 0.125646 0.076623 0.170158 -0.149555 -0.113883 0
inflation_star(-1) -0.869578 0.453172 -0.251527 0.787104 0.545697 0.952500
Taylor_shock -0.727650 -0.346316 -0.893687 -0.112214 -0.667002 0
output_shock 0.247218 0.099712 0.286727 -0.029794 -0.043756 0
philip_shock -3.387905 -1.462685 -4.019950 0.725356 0.818566 0
world_output_shock -0.365049 1.212666 0.135526 0.417899 0.267306 0.500000
inflation_star_shock -1.369414 0.713656 -0.396106 1.239534 0.859365 1.500000
is_shock 1.606610 -0.259140 1.009129 0.023077 -0.068709 0


MOMENTS OF SIMULATED VARIABLES

VARIABLE MEAN STD. DEV. VARIANCE SKEWNESS KURTOSIS
c -0.270005 0.926508 0.858418 0.205329 0.098846
ex -0.289002 1.654892 2.738669 0.032568 -0.705557
y -0.293114 1.153794 1.331241 0.242255 0.047557
ii 0.116417 0.442828 0.196097 -0.119104 -0.250051
inflation 0.062351 0.283967 0.080637 -0.064207 -0.284675
i_star 0.029219 0.311366 0.096949 -0.044594 0.110429


CORRELATION OF SIMULATED VARIABLES

VARIABLE c ex y ii inflation i_star
c 1.0000 0.5600 0.9360 -0.8801 -0.8544 -0.1395
ex 0.5600 1.0000 0.7883 -0.6061 -0.5642 0.4023
y 0.9360 0.7883 1.0000 -0.8549 -0.8368 0.1297
ii -0.8801 -0.6061 -0.8549 1.0000 0.9148 0.2842
inflation -0.8544 -0.5642 -0.8368 0.9148 1.0000 0.1537
i_star -0.1395 0.4023 0.1297 0.2842 0.1537 1.0000


AUTOCORRELATION OF SIMULATED VARIABLES

VARIABLE 1 2 3 4 5
c 0.8758 0.6989 0.5216 0.3803 0.2775
ex 0.9786 0.9341 0.8727 0.8027 0.7281
y 0.9140 0.7772 0.6363 0.5164 0.4228
ii 0.8756 0.6825 0.5021 0.3479 0.2310
inflation 0.7773 0.5776 0.4249 0.2736 0.1663
i_star 0.8268 0.5779 0.3789 0.2523 0.1724
Total computing time : 0h00m06s








jpfeifer wrote:One problem definitely is that equation 3
Code: Select all
b = (1+ii(-1)-inflation)*b(-1)+y(-1)-c(-1)-delta*s(-1);                     

is not linear, although you use
Code: Select all
model(linear)

You might want to use the unstable version for this.
jcsantanac
 
Posts: 16
Joined: Fri Jan 03, 2014 2:08 am

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jpfeifer » Sat Oct 01, 2016 7:15 am

As mentioned at http://www.dynare.org/DynareWiki/KnownBugs, there was a bug in 4.4.3 that
When falsely specifying the model(linear) for nonlinear models, incorrect steady states were accepted instead of aborting

Thus, you cannot trust version other than the unstable version with your mod-file. The
Code: Select all
(linear)

option of the model block does not indicate to Dynare that linearization is to be done, but that you (the user) provides an already linear model, which is clearly not the case. Use
Code: Select all
order=1

for that. The issue when doing that is to correctly link the relation ship between the variables. You cannot have i represent the level of interest rates in one equation and the percentage deviation from interest its steady state in another. See http://www.dynare.org/phpBB3/viewtopic.php?f=2&t=7946
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jcsantanac » Thu Oct 06, 2016 1:53 am

Prof. Pfeifer, Thanks for your advices. I ran the code on unstable version (2016-09-29) and works ok.

Now, I would like to ask you about the shock_decomposition command 'cause i want to graph the variance decomposition of all my observable variables (c_obs, y_obs, ex_obs, inflation_obs, ii_obs, i_star_obs) but i get the following error; nevertheless dynare exhibits a global variance decomposition at the final of the output.

Error using makedataset (line 213)
makedataset: first_obs (1Y) - 1 cannot be less than the first date in the dataset (1Y)!
Reduce the number of lags in the VAR model or increase the value of first_obs
to at least first_obs=2.

Error in dynare_estimation_init (line 542)
[dataset_, dataset_info, newdatainterfaceflag] = makedataset(options_,
options_.dsge_var*options_.dsge_varlag, gsa_flag);

Error in evaluate_smoother (line 59)
[dataset_,dataset_info,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list, M_.fname, [], M_, options_, oo_, estim_params_,
bayestopt_);

Error in shock_decomposition (line 67)
[oo,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist);

I am running a DSGEVAR(1) and I put "first_obs=2" in the estimation command. After run estimation and dynare calls shock_decomposition, I think the error could be related with the argument "options_.first_obs" that is equal to 1 but different from the specified in the estimation command (first_obs=2). How could I fix this problem?

I Append the code and database. Thanks Prof.! I appreciate any suggestion!.


Posterior mean variance decomposition (in percent)
Taylor_shock output_shock philip_shock world_output_shock inflation_star_shock is_shock
c_obs 5.39 0.44 17.18 13.90 21.92 41.17
ex_obs 3.83 0.35 11.60 47.07 34.88 2.27
y_obs 11.88 24.93 36.35 4.75 11.51 10.58
ii_obs 28.60 0.53 26.48 13.36 28.70 2.34
inflation_obs 5.90 0.28 73.41 5.55 14.25 0.60
i_star_obs 0.00 0.00 0.00 36.23 63.77 0.00

Done!
Estimation::mcmc: Forecasted variables (mean)
Estimation::mcmc: Forecasted variables (mean), done!
Estimation::mcmc: Forecasted variables (point)
Estimation::mcmc: Forecasted variables (point), done!


jpfeifer wrote:As mentioned at http://www.dynare.org/DynareWiki/KnownBugs, there was a bug in 4.4.3 that
When falsely specifying the model(linear) for nonlinear models, incorrect steady states were accepted instead of aborting

Thus, you cannot trust version other than the unstable version with your mod-file. The
Code: Select all
(linear)

option of the model block does not indicate to Dynare that linearization is to be done, but that you (the user) provides an already linear model, which is clearly not the case. Use
Code: Select all
order=1

for that. The issue when doing that is to correctly link the relation ship between the variables. You cannot have i represent the level of interest rates in one equation and the percentage deviation from interest its steady state in another. See http://www.dynare.org/phpBB3/viewtopic.php?f=2&t=7946
Attachments
DATABfl.m
Data Sim
(46.97 KiB) Downloaded 56 times
modelo.mod
Code
(5.22 KiB) Downloaded 60 times
jcsantanac
 
Posts: 16
Joined: Fri Jan 03, 2014 2:08 am

Re: COLLINEARITY PROBLEM NKOPEN ECONOMY DSGE MODEL

Postby jpfeifer » Thu Oct 06, 2016 12:34 pm

That is kind of a bug we will fix. For now, simply put
Code: Select all
options_.first_obs=2;
options_.nobs=499;

before shock_decomposition.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 10 guests