Page 1 of 1

simulation

PostPosted: Wed Nov 30, 2016 2:20 pm
by econphd
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.

Re: simulation

PostPosted: Thu Dec 01, 2016 3:51 pm
by jpfeifer
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.

Re: simulation

PostPosted: Thu Dec 01, 2016 7:30 pm
by econphd
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,

Re: simulation

PostPosted: Thu Dec 01, 2016 8:14 pm
by jpfeifer
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.

Re: simulation

PostPosted: Sun Dec 04, 2016 3:04 pm
by econphd
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

Re: simulation

PostPosted: Sun Dec 04, 2016 5:06 pm
by jpfeifer
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.

Re: simulation

PostPosted: Sun Dec 04, 2016 8:42 pm
by econphd
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,

Re: simulation

PostPosted: Mon Dec 05, 2016 6:47 am
by jpfeifer
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.

Re: simulation

PostPosted: Mon Dec 05, 2016 12:05 pm
by econphd
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

Re: simulation

PostPosted: Mon Dec 05, 2016 7:40 pm
by jpfeifer
Yes, that seems correct.