Page 2 of 2

Re: non linear gmm

Posted: Fri Dec 11, 2015 11:49 pm
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.

Re: non linear gmm

Posted: Sat Dec 12, 2015 6:03 am
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.

Re: non linear gmm

Posted: Sat Dec 12, 2015 10:18 pm
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.

Re: non linear gmm

Posted: Sun Dec 13, 2015 8:18 pm
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.

Re: non linear gmm

Posted: Sun Dec 13, 2015 9:04 pm
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
*

Re: non linear gmm

Posted: Sun Dec 13, 2015 9:08 pm
by TomDoan
That looks correct.

Re: non linear gmm

Posted: Thu Jan 14, 2016 3:23 am
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?

Re: non linear gmm

Posted: Thu Jan 14, 2016 10:04 am
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.

Re: non linear gmm

Posted: Fri Jan 15, 2016 3:29 am
by cczzwhy
Thank you very much! And is there any procedure in rats can replicate the weak identification test in Stock and wright(2000)?