Estimation of Consumption CAPM using GMM

43 views
Skip to first unread message

Cheikh Ibrahima Nokho

unread,
Nov 16, 2019, 1:27:28 PM11/16/19
to pystatsmodels
Hi All,

I was trying to implement a Consumption-based CAPM using the GMM.NonlinearIVGMM function of Statsmodel.
I have several moment conditions (one moment for each asset).

Is there anyway to include for example 5 moment conditions (equations)?

There is only one argument (func) in the fonction GMM.NonlinearIVGMM.

Cheikh




josef...@gmail.com

unread,
Nov 16, 2019, 1:47:15 PM11/16/19
to pystatsmodels
The moment conditions are in columns, so they should be a 2-D array when evaluated at the parameters.
If the instruments are not common to all moment conditions, then IV doesn't work directly and instruments need to be incorporated in each column.
(IIRC, I have an example where the instrument is just a vector of ones, and the nonlinear moment conditions in the columns include the instruments)

Do you have the equations for the moment conditions?

We have some simple CAPM with GMM examples, but I haven't looked at this in a long time.

Josef


 

Cheikh




--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystatsmodel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/63534c88-104f-4e05-a1aa-ae35539c1b7b%40googlegroups.com.

josef...@gmail.com

unread,
Nov 16, 2019, 2:02:03 PM11/16/19
to pystatsmodels
On Sat, Nov 16, 2019 at 1:46 PM <josef...@gmail.com> wrote:


On Sat, Nov 16, 2019 at 1:27 PM Cheikh Ibrahima Nokho <cheikhibra...@gmail.com> wrote:
Hi All,

I was trying to implement a Consumption-based CAPM using the GMM.NonlinearIVGMM function of Statsmodel.
I have several moment conditions (one moment for each asset).

Is there anyway to include for example 5 moment conditions (equations)?

There is only one argument (func) in the fonction GMM.NonlinearIVGMM.

The moment conditions are in columns, so they should be a 2-D array when evaluated at the parameters.
If the instruments are not common to all moment conditions, then IV doesn't work directly and instruments need to be incorporated in each column.
(IIRC, I have an example where the instrument is just a vector of ones, and the nonlinear moment conditions in the columns include the instruments)

Do you have the equations for the moment conditions?

We have some simple CAPM with GMM examples, but I haven't looked at this in a long time.

I don't find anything searching for "CAPM" in our github repo

an old gist of mine with nonlinear euler equations

Cheikh Ibrahima Nokho

unread,
Nov 16, 2019, 2:05:22 PM11/16/19
to pystatsmodels
Thanks for your reply.

It is a CCAPM with a power utility function (find attached the equation where i denotes a country). 
For my case, I have 5 countries (the G5 countries).

Does it mean that I need to create a function representing the moment condition with a 5 columns matrix as output?

Cheikh
Screen Shot 2019-11-16 at 1.55.47 PM.png

josef...@gmail.com

unread,
Nov 16, 2019, 2:23:28 PM11/16/19
to pystatsmodels
On Sat, Nov 16, 2019 at 2:05 PM Cheikh Ibrahima Nokho <cheikhibra...@gmail.com> wrote:
Thanks for your reply.

It is a CCAPM with a power utility function (find attached the equation where i denotes a country). 
For my case, I have 5 countries (the G5 countries).

Does it mean that I need to create a function representing the moment condition with a 5 columns matrix as output?

5 times the number of parameters if parameters are country specific

In the actual computation we need at least as many moment conditions as parameters.
Each moment condition is a column, and the weight and covariance matrices are computed for these columns.

special case IV
Z * (y - f(x, params))
or if y is set to zero and f is negated, then  `Z * f(x, params)`

AFAIR, in this case  `(y - f(x, params))` has to be scalar like the residual for the univariate case (a single column)
Then, the number of moment conditions are coming from the number of instruments, columns of Z.

AFAIR, it is not possible that both Z and  (y - f(x, params)) have more than one column (breaks numpy broadcasting and would need a definition different from standard linalg).

If Z=ones, y=zeros, then we are essentially back to generic nonlinear GMM where f(y, x, params) fully specifies moment conditions.

Josef




 

josef...@gmail.com

unread,
Nov 16, 2019, 2:26:51 PM11/16/19
to pystatsmodels
On Sat, Nov 16, 2019 at 2:23 PM <josef...@gmail.com> wrote:


On Sat, Nov 16, 2019 at 2:05 PM Cheikh Ibrahima Nokho <cheikhibra...@gmail.com> wrote:
Thanks for your reply.

It is a CCAPM with a power utility function (find attached the equation where i denotes a country). 
For my case, I have 5 countries (the G5 countries).

Does it mean that I need to create a function representing the moment condition with a 5 columns matrix as output?

5 times the number of parameters if parameters are country specific

In the actual computation we need at least as many moment conditions as parameters.
Each moment condition is a column, and the weight and covariance matrices are computed for these columns.

I never tried this:
If moments are only correlated within a country but not between countries, then I think the appropriate structure would be a block diagonal moment matrix with each country forming a block in different rows.

Cheikh Ibrahima Nokho

unread,
Nov 16, 2019, 2:37:20 PM11/16/19
to pystatsmodels
Thank for the notebook and the explanations.

I am implementing it right now.

Cheikh

On Saturday, November 16, 2019 at 2:26:51 PM UTC-5, josefpktd wrote:


On Sat, Nov 16, 2019 at 2:23 PM <jose...@gmail.com> wrote:


On Sat, Nov 16, 2019 at 2:05 PM Cheikh Ibrahima Nokho <cheikhibr...@gmail.com> wrote:
Thanks for your reply.

It is a CCAPM with a power utility function (find attached the equation where i denotes a country). 
For my case, I have 5 countries (the G5 countries).

Does it mean that I need to create a function representing the moment condition with a 5 columns matrix as output?

5 times the number of parameters if parameters are country specific

In the actual computation we need at least as many moment conditions as parameters.
Each moment condition is a column, and the weight and covariance matrices are computed for these columns.

I never tried this:
If moments are only correlated within a country but not between countries, then I think the appropriate structure would be a block diagonal moment matrix with each country forming a block in different rows.
 

special case IV
Z * (y - f(x, params))
or if y is set to zero and f is negated, then  `Z * f(x, params)`

AFAIR, in this case  `(y - f(x, params))` has to be scalar like the residual for the univariate case (a single column)
Then, the number of moment conditions are coming from the number of instruments, columns of Z.

AFAIR, it is not possible that both Z and  (y - f(x, params)) have more than one column (breaks numpy broadcasting and would need a definition different from standard linalg).

If Z=ones, y=zeros, then we are essentially back to generic nonlinear GMM where f(y, x, params) fully specifies moment conditions.

Josef




 

Cheikh
On Nov 16, 2019, 1:47 PM -0500, jose...@gmail.com, wrote:


On Sat, Nov 16, 2019 at 1:27 PM Cheikh Ibrahima Nokho <cheikhibr...@gmail.com> wrote:
Hi All,

I was trying to implement a Consumption-based CAPM using the GMM.NonlinearIVGMM function of Statsmodel.
I have several moment conditions (one moment for each asset).

Is there anyway to include for example 5 moment conditions (equations)?

There is only one argument (func) in the fonction GMM.NonlinearIVGMM.

The moment conditions are in columns, so they should be a 2-D array when evaluated at the parameters.
If the instruments are not common to all moment conditions, then IV doesn't work directly and instruments need to be incorporated in each column.
(IIRC, I have an example where the instrument is just a vector of ones, and the nonlinear moment conditions in the columns include the instruments)

Do you have the equations for the moment conditions?

We have some simple CAPM with GMM examples, but I haven't looked at this in a long time.

Josef


 

Cheikh




--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystat...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystat...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystat...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages