non linear gmm

Econometrics questions and discussions
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: non linear gmm

Unread post by cczzwhy »

Thank you very much for your suggestion! If we take the E(f/g-1) form,is the following code OK?

Code: Select all

*
nonlin discount riskaver aconsum
frml h1 = discount*realret1(t)*((c+aconsum*c{1})^riskaver+discount*(c{-1}+aconsum*c)^riskaver)/((c{1}+aconsum*c{2})^riskaver+discount*(c+aconsum*c{1})^riskaver)-1
frml h2 = discount*realret2(t)*((c+aconsum*c{1})^riskaver+discount*(c{-1}+aconsum*c)^riskaver)/((c{1}+aconsum*c{2})^riskaver+discount*(c+aconsum*c{1})^riskaver)-1
compute discount = .99,riskaver = -.95,aconsum=0

*
compute start=%regstart()
dofor nlag = 1 2 4 6
  instruments constant c{1 to nlag} realret1{1 to nlag} realret2{1 to nlag}
  nlsystem(instruments,zudep) /h1 h2
  cdf(title="Specification Test for "+nlag+" lags") $
     chisqr %uzwzu 6*nlag
end dofor
*
The result is attached.
Attachments
euler4.RPF
(3.55 KiB) Downloaded 1025 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: non linear gmm

Unread post by TomDoan »

Did you try redating that back a period (to expectation at t-1?) Your formula is all wrong for that. Again C{2} is c(t-2), C{3} is c(t-3). Those should never enter into that.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: non linear gmm

Unread post by cczzwhy »

In the formula,we want R(t+1),S(t)=C(t)+a*C(t-1),S(t+1)=C(t+1)+a*C(t),S(t+2)=C(t+2)+a*C(t+1),so should it be

Code: Select all

nonlin discount riskaver aconsum
frml h1 = discount*realret1(t)*((c(t)+aconsum*c(t-1)^riskaver+discount*(c(t+1)+aconsum*c(t))^riskaver)/((c(t-1)+aconsum*c(t-2))^riskaver+discount*(c(t)+aconsum*c(t-1))^riskaver)-1
frml h2 = discount*realret2(t)*((c(t)+aconsum*c(t-1)^riskaver+discount*(c(t+1)+aconsum*c(t))^riskaver)/((c(t-1)+aconsum*c(t-2))^riskaver+discount*(c(t)+aconsum*c(t-1))^riskaver)-1
compute discount = .99,riskaver = -.95,aconsum=0
or

Code: Select all

nonlin discount riskaver aconsum
frml h1 = discount*realret1(t+1)*((c(t+1)+aconsum*c(t)^riskaver+discount*(c(t+2)+aconsum*c(t+1))^riskaver)/((c(t)+aconsum*c(t-1))^riskaver+discount*(c(t+1)+aconsum*c(t))^riskaver)-1
frml h2 = discount*realret2(t+1)*((c(t+1)+aconsum*c(t)^riskaver+discount*(c(t+2)+aconsum*c(t+1))^riskaver)/((c(t)+aconsum*c(t-1))^riskaver+discount*(c(t+1)+aconsum*c(t))^riskaver)-1
compute discount = .99,riskaver = -.95,aconsum=0
Sorry for my English understanding.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: non linear gmm

Unread post by TomDoan »

You're applying the ^riskaver to the wrong thing---you're missing a grouping parenthesis on the S. You can make this easier to write by creating a sub-FRML to define S^riskaver:

frml SRISK = (c+aconsum*c{1})^riskaver

so you can write the main FRML as something like

frml h1 = realret(t)*discount*(srisk(t)+aconsum*discount*srisk(t+1))/(srisk(t-1)+aconsum*beta*srisk(t))-1

Once corrected, your first FRML is for an information set dated t-1 and the second for t. You can use either, you just have to take the proper lags on the conditioning variables given the date for the information.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: non linear gmm

Unread post by cczzwhy »

Thank u for your help and your patience.Do you mean it should be like this?

Code: Select all

*
nonlin discount riskaver aconsum
frml SRISK = (c+aconsum*c{1})^riskaver
frml h1 = realret1(t)*discount*(srisk(t)+aconsum*discount*srisk(t+1))/(srisk(t-1)+aconsum*discount*srisk(t))-1
frml h2 = realret2(t)*discount*(srisk(t)+aconsum*discount*srisk(t+1))/(srisk(t-1)+aconsum*discount*srisk(t))-1
compute discount = .99,riskaver = -.95,aconsum=0

*
compute start=%regstart()
dofor nlag = 1 2 4 6
  instruments constant c{1 to nlag} realret1{1 to nlag} realret2{1 to nlag}
  nlsystem(instruments,zudep) /h1 h2
  cdf(title="Specification Test for "+nlag+" lags") $
     chisqr %uzwzu 6*nlag
end dofor
*
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: non linear gmm

Unread post by TomDoan »

That looks correct.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: non linear gmm

Unread post by cczzwhy »

Hello,Tom!I want to ask about that is there any option I can add into nlsystem to make the results as same to 2SLS?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: non linear gmm

Unread post by TomDoan »

NLSYSTEM with the CV option where CV is a diagonal matrix will give the 2SLS point estimates, that is, something like:

nlsystem(inst,cv=%identity(3)) / consfrml invfrml wagefrml

If you do a second pass with that feeding in the diagonal elements from the first stage, you'll get close to the 2SLS standard errors as well:

nlsystem(inst,cv=%diag(%xdiag(%sigma))) / consfrml invfrml wagefrml

except that NLLS does a degrees of freedom correction on the variances on an equation by equation basis, so the NLLS standard errors will be somewhat larger.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: non linear gmm

Unread post by cczzwhy »

Thank you very much! And is there any procedure in rats can replicate the weak identification test in Stock and wright(2000)?
Post Reply