simulation

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.

simulation

Postby econphd » Wed Nov 30, 2016 2:20 pm

Dear Johannes,
The model that I am using now generates negative values so I could not use this data in VAR. My question is that why my model cannot generate positives values? Could you please give me some advice how I could generate the data in positives values? Also, this model should show me that A_t can only have a long run effect on labor productivity and cause hours to be non-stationary because of unit root.

BTW, my aim is to compare SVARs IRFs to IRFs generated from same SVAR estimated on data generate from the model.

Many thanks.
Attachments
mfile.mod
(2.11 KiB) Downloaded 88 times
Last edited by econphd on Sat Dec 03, 2016 9:16 am, edited 1 time in total.
econphd
 
Posts: 31
Joined: Fri Mar 25, 2016 2:39 pm

Re: simulation

Postby jpfeifer » Thu Dec 01, 2016 3:51 pm

The reason is that you are still not correctly rebuilding the trending time series. The idea behind separating trend and cycle is that the observed series is the product of a stationary component providing deviations from trend and a trend component. In logs, the two would be additive. What you do in your mod-file is adding the unlogged level of output to the logged trend. That cannot work. Your output should rather be
Code: Select all
exp(log(y(ii,1))+log_A(ii,1)+log_B(ii,1))

i.e. you sum up the log components and then invert the logging. The exp() will then assure that the series is positive.
------------
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: simulation

Postby econphd » Thu Dec 01, 2016 7:30 pm

Dear Johannes,

Many thanks for this. Now, I added the logged level of output to the logged trend but I still have an issue to obtain positive values. I could be misunderstood your suggestion. Just for clarification, should I add new variables to the model like:
model;
log_y = log(y)
steady state model;
log_y = log(y) ?

I would really appreciate if you could look at this code again. I am really sorry but I am working on it since long time and I could not figure out the problem so I could not solve it.

Best,
Attachments
mfile.mod
(2.02 KiB) Downloaded 81 times
econphd
 
Posts: 31
Joined: Fri Mar 25, 2016 2:39 pm

Re: simulation

Postby jpfeifer » Thu Dec 01, 2016 8:14 pm

You are using a shock standard deviation of 100%. Of course you get negative output when your average shock brings TFP from 1 to 0.
------------
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: simulation

Postby econphd » Sun Dec 04, 2016 3:04 pm

Dear Johannes,

Thank you so much for your help. This model now generated the data in positive values. I have one last question. In this model, the data generated for variables:

1. in level (the data come in levels and have to log it to build the log-level variables) or 2. in %deviations from steady state(so i know that I do not need to log anything to build the levels of the variables) ??

Many thanks
econphd
 
Posts: 31
Joined: Fri Mar 25, 2016 2:39 pm

Re: simulation

Postby jpfeifer » Sun Dec 04, 2016 5:06 pm

Dynare by default does linearization, not loglinearizations. Thus, everything is in levels (unless you loglinearized the model yourself or used the loglinear option). Of course, if your defined variable is already a log-level (like having log_y=log(y)) then you get a log-level.
------------
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: simulation

Postby econphd » Sun Dec 04, 2016 8:42 pm

Dear Johannes,

Many thanks for this. I think that I finalized the codes with your help. Does this model gives me non-stationary log-level variables to use in VAR? I think the answer is yes but I just want to confirm with you
that I defined the variables correctly in below.

var c k y B h A y_h i w r g_A g_B log_y log_h log_y_h;
varexo eps_a eps_b;

parameters delta psi alpha beta ;

% Parameter Values

beta = 0.95;
psi = 0.33;
alpha = 0.68;
delta = 0.07;


Model;

y = k(-1)^(1-alpha)*exp(eps_a+eps_b)^(alpha-1)*h^alpha;
g_A=eps_a;
g_B=eps_b;
log(A)=log(A(-1)) + eps_a;
log(B)=log(B(-1)) + eps_b;
r = (1-alpha)*(y/k(-1))*exp(eps_a+eps_b);
w= alpha*(y/(h*B)); %7
c^(-1)= exp(eps_a(+1)*eps_b(+1))^(-1)*beta*c(+1)^(-1)*(1+r(+1)-delta);
h^(1/psi)*B^(-1) = c^(-1)*w; %9
y_h = y/(h*B); %10
c + k = y + (1-delta)*k(-1)*exp(eps_a+eps_b)^(-1);
i = y-c;


// use logarithm to get variables in percentage deviations
log_y=log(y);
log_h=log(h);
log_y_h=log(y_h);
end;




steady_state_model;
A=1;
B=1;
r=(1/beta)-(1-delta);
y_k=r/(1-alpha);
k_y=(1-alpha)/r;
i_y=(1/y_k)*delta;
c_y=1-i_y;
h= (alpha*1/c_y)^(psi/(1+psi));
k=((h^alpha)/y_k)^(1/alpha);
y=k^(1-alpha)*h^alpha;
c=c_y*y;
i=i_y*y;
y_h =y/h;
w=alpha*(y_h);
log_y=log(y);
log_h=log(h);
log_y_h=log(y_h);
end;


shocks;
var eps_a; stderr 0.01;
var eps_b; stderr 0.01;
end;
resid(1);
steady;
check;


stoch_simul(order=1, periods=1000,drop=960) y h y_h;


// Rebuild non-stationary time series by remultiplying with A_{t} and B_{t}

log_A_0=0; //Initialize Level of Technology at t=0;
log_B_0=0; //Initialize Level of Technology at t=0;
log_A(1,1)=log_A_0 ; //Level of Tech. after shock in period 1
log_B(1,1)=log_B_0; //Level of Tech. after shock in period 1

// reaccumulate the non-stationary level series

for ii=1:options_.periods

log_A(ii+1,1)=log_A(ii,1)+g_A(ii,1);
log_B(ii+1,1)=log_B(ii,1)+g_B(ii,1);
log_y_nonstationary(ii+1,1)=exp(log_y(ii,1)+log_A(ii,1)+log_B(ii,1));
log_h_nonstationary(ii+1,1)=exp(log_h(ii,1)+log_B(ii,1));
log_y_h_nonstationary(ii+1,1)=exp(log_y_h(ii,1)+log_A(ii,1)+log_B(ii,1));
end

Many thanks,
econphd
 
Posts: 31
Joined: Fri Mar 25, 2016 2:39 pm

Re: simulation

Postby jpfeifer » Mon Dec 05, 2016 6:47 am

No, that is not correct. You must keep track of what you log and what not. According to your decomposition, trend and cycle are additive in logs. For that reason
Code: Select all
log_y_h_nonstationary(ii+1,1)=exp(log_y_h(ii,1)+log_A(ii,1)+log_B(ii,1));

cannot be right. Already the part
Code: Select all
log_y_h(ii,1)+log_A(ii,1)+log_B(ii,1)

is
Code: Select all
log_y_h_nonstationary

By taking exp() again you get the level, not the log-level.
------------
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: simulation

Postby econphd » Mon Dec 05, 2016 12:05 pm

Dear Johannes, thanks a lot. I understood your point.

such as:

log_h_nonstationary(ii+1,1)=log_h(ii,1)+log_A(ii,1)+log_B(ii,1); is the correct way to define h. With this, both my shocks and hours are in logs and this model generates non-stationary log-level hours to use in VAR.

In addition, this model shows the labor suppy shock (B) has a permanent effect on hours but it does not have a permanent effect on labor productivity. In addition, technology shock (A) is the only shock that can have a long run effect on productivity. Am I interpreting this model correctly?

Many thanks
econphd
 
Posts: 31
Joined: Fri Mar 25, 2016 2:39 pm

Re: simulation

Postby jpfeifer » Mon Dec 05, 2016 7:40 pm

Yes, that seems correct.
------------
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 contributions and examples

Who is online

Users browsing this forum: No registered users and 4 guests