Você está na página 1de 60

Outline

GMM in finance
GMM with R
GEL in finance
Whats next?

GMM and GEL with R

Pierre Chauss1

UQM and CIRPE

Rmetrics Workshop 2009

1
Special thanks to Rmetrics Association and its partners for financial
support.
Pierre Chauss GMM and GEL with R
Outline
GMM in finance
GMM with R
GEL in finance
Whats next?

1 GMM in finance
The generalized method of moments
Consumption-CAPM
Linear factor pricing models
Nonlinear factor models
Continuous time processes
2 GMM with R
The function gmm()
Linear models
Nonlinear models
3 GEL in finance
The generalized empirical likelihood
GEL with R
4 Whats next?
Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Articles on which this presentation is based:

Chauss(2009), "Computing Generalized Empirical


Likelihood and Generalized Method of Moments with R"

Jagannathan, Skoulakis and Wang(2002), "Generalized


Method of Moments: Applications in Finance", JBES

Cochrane(2001), "Asset Pricing", Princeton University


Press
Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM

We want to estimate the vector of parameters 0 Rp based on


either h i
E g(0 , xt ) = 0
or h i
E g(0 , xt )|It = 0,

where g() is a q 1 vector of moment conditions, with q p,


and It is an information set. The conditional moment conditions
can be replaced by the following unconditional moment
conditions: h i
E g(0 , xt )f (zt ) = 0,

where zt It and f () is any function.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM

We want to estimate the vector of parameters 0 Rp based on


either h i
E g(0 , xt ) = 0
or h i
E g(0 , xt )|It = 0,

where g() is a q 1 vector of moment conditions, with q p,


and It is an information set. The conditional moment conditions
can be replaced by the following unconditional moment
conditions: h i
E g(0 , xt )f (zt ) = 0,

where zt It and f () is any function.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM

We want to estimate the vector of parameters 0 Rp based on


either h i
E g(0 , xt ) = 0
or h i
E g(0 , xt )|It = 0,

where g() is a q 1 vector of moment conditions, with q p,


and It is an information set. The conditional moment conditions
can be replaced by the following unconditional moment
conditions: h i
E g(0 , xt )f (zt ) = 0,

where zt It and f () is any function.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: The estimator


The GMM estimator is defined as
= arg min g() W g(),

where
T
1X
g() = g(, xt )
T
t=1
The asymptotic efficiency is achieved if the matrix W is the
inverse
of a consistent estimate of the covariance matrix of
T g() defined as:

X
() = Cov[g(, xt ), g(, xt+s )]
s=

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: The estimator


The GMM estimator is defined as
= arg min g() W g(),

where
T
1X
g() = g(, xt )
T
t=1
The asymptotic efficiency is achieved if the matrix W is the
inverse
of a consistent estimate of the covariance matrix of
T g() defined as:

X
() = Cov[g(, xt ), g(, xt+s )]
s=

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: The HAC estimator


() is estimated by the following heteroskedasticity and
autocorrelation consistent estimator (HAC):
T
X 1
( ) = kh (s)s ( )
s=(T 1)

where, kh (s) is a kernel, h is the bandwidth which can be


chosen using a procedure such as the ones proposed by
Newey-West(1987a) or Andrews(1991),
1X
s ( ) = g( , xt )g( , xt+s )
T
t

and is a convergent estimate of 0 .


Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: The three methods

Two step GMM (Hansen (1982))


1) = arg min g() g()
2) = arg min g() ( )1 g()
Iterated GMM (Hansen-Eaton-Yaron (1996))
1) (1) = arg min g() g()
2) (2) = arg min g() ((1) )1 g()
3) (1) = arg min g() ((2) )1 g() and go back to 2) until
convergence.
Continuous updated GMM (Hansen-Eaton-Yaron (1996))

= arg min g() ()1 g()


Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: The three methods

Two step GMM (Hansen (1982))


1) = arg min g() g()
2) = arg min g() ( )1 g()
Iterated GMM (Hansen-Eaton-Yaron (1996))
1) (1) = arg min g() g()
2) (2) = arg min g() ((1) )1 g()
3) (1) = arg min g() ((2) )1 g() and go back to 2) until
convergence.
Continuous updated GMM (Hansen-Eaton-Yaron (1996))

= arg min g() ()1 g()


Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: The three methods

Two step GMM (Hansen (1982))


1) = arg min g() g()
2) = arg min g() ( )1 g()
Iterated GMM (Hansen-Eaton-Yaron (1996))
1) (1) = arg min g() g()
2) (2) = arg min g() ((1) )1 g()
3) (1) = arg min g() ((2) )1 g() and go back to 2) until
convergence.
Continuous updated GMM (Hansen-Eaton-Yaron (1996))

= arg min g() ()1 g()


Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: Properties
Given some regularity conditions, the GMM estimator
converges as T goes to infinity to the following distribution:
L
T ( 0 ) N(0, V ),

where
   
g(0 , xt ) g(0 , xt )
V =E (0 )1 E

Finally, we can test the (q p) overidentifying restrictions using
the result that, under the null H0 : E [g(, xt )] = 0:
L
T g() [( )]1 g() 2qp

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

GMM: Properties
Given some regularity conditions, the GMM estimator
converges as T goes to infinity to the following distribution:
L
T ( 0 ) N(0, V ),

where
   
g(0 , xt ) g(0 , xt )
V =E (0 )1 E

Finally, we can test the (q p) overidentifying restrictions using
the result that, under the null H0 : E [g(, xt )] = 0:
L
T g() [( )]1 g() 2qp

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

C-CAPM

The micro-foundations of the pricing equation:

E (mt+1 Ri,t+1 |It ) = 1 for i = 1, ..., N,

where Ri,t is the gross return of asset i and mt+1 is the


stochastic discount factor, are based on the maximization of the
expected present value of the lifetime utility of a representative
investor.
This problem results in the following moment conditions
 
U (Ct+1 )
E Ri,t+1 It = 1
U (Ct )

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

C-CAPM

The micro-foundations of the pricing equation:

E (mt+1 Ri,t+1 |It ) = 1 for i = 1, ..., N,

where Ri,t is the gross return of asset i and mt+1 is the


stochastic discount factor, are based on the maximization of the
expected present value of the lifetime utility of a representative
investor.
This problem results in the following moment conditions
 
U (Ct+1 )
E Ri,t+1 It = 1
U (Ct )

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

C-CAPM
If the utility is given by the popular constant relative risk
aversion function
 1
z /(1 ) if 6= 1
U(z) = ,
log z if = 1

The moment conditions become:



"   #
C t+1
1
E
Ct = 0 for i = 1, ..., N
Ri,t+1 zt

| {z }
g(,xt )

where zt It .
Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

CAPM

The CAPM implies the following relations:

E (Rit ) Rf = i [E (Rm,t ) Rf ] for i = 1, ..., N

which can be tested using the following regression:

Rit Rf = i + i (Rm,t Rf ) + it for i = 1, ..., N

It can be estimated by GMM using:


 
1
g(, xt ) = t
(Rm,t Rf )

where t = {1t , ..., Nt } and is the Kronecker product.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

CAPM

The CAPM implies the following relations:

E (Rit ) Rf = i [E (Rm,t ) Rf ] for i = 1, ..., N

which can be tested using the following regression:

Rit Rf = i + i (Rm,t Rf ) + it for i = 1, ..., N

It can be estimated by GMM using:


 
1
g(, xt ) = t
(Rm,t Rf )

where t = {1t , ..., Nt } and is the Kronecker product.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

CAPM

The CAPM implies the following relations:

E (Rit ) Rf = i [E (Rm,t ) Rf ] for i = 1, ..., N

which can be tested using the following regression:

Rit Rf = i + i (Rm,t Rf ) + it for i = 1, ..., N

It can be estimated by GMM using:


 
1
g(, xt ) = t
(Rm,t Rf )

where t = {1t , ..., Nt } and is the Kronecker product.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

CAPM

The restricted regression:

Rit Rf = i (Rm,t Rf ) + it for i = 1, ..., N

allows the testing of the theory through the J-Test of


overidentifying restrictions (2N conditions, N coefficients to
estimate).

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

CAPM-Black

In the Black version, Rf does not exist and is replaced by , the


expected return of the zero-beta. The model implies:

Rit = + i (Rm,t ) + it

The moment conditions are:


  
1
E t =0
(Rm,t Rf )

There are 2N conditions and N + 1 parameters. The test of


overidentifying restrictions can be used to test the theory.

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Factor models: SDF representation


We can test the pricing conditions:
E (mRi ) = 1 for i = 1, ..., N
using the stochastic discount factor m implied by the factor
models as shown by Hansen and Richard(1987). For the
CAPM, the discount factor is mt = 0 + 1 Rmt . The moment
conditions become:
h i
E Rit (0 1 Rmt ) 1 = 0 for i = 1, ..., N

For the multi-factor model, the SDF is:


k
X
mt = 0 + s fst
s=1

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Factor models: SDF representation


We can test the pricing conditions:
E (mRi ) = 1 for i = 1, ..., N
using the stochastic discount factor m implied by the factor
models as shown by Hansen and Richard(1987). For the
CAPM, the discount factor is mt = 0 + 1 Rmt . The moment
conditions become:
h i
E Rit (0 1 Rmt ) 1 = 0 for i = 1, ..., N

For the multi-factor model, the SDF is:


k
X
mt = 0 + s fst
s=1

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Nonlinear factor models: SDF representation


Based on some assumptions on the investors preference,
Bansal and Viswanathan(1993) propose the following SDF
(single factor model):
k
X
mt = 0 + 1 rf + s (rmt rf )s
s=1
Bansal, Hsieh, and Viswanathan(1993) propose a modification
of the previous study with an SDK based on a neural network
approach:
k
X
mt = 0 + 1 rf + s h(0s + 1s rmt )
s=1
ex
with h(x) = ex +1
Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Discrete time approximations


Several continuous time processes for the term structure of
interest rate is embedded in the following process:
drt = ( + rt )dt + rt dWt

= 0 and = 0: Brownian motion with drift


= 0: Ornstein-Uhlenbeck process
= 1/2: Cox-Ingersoll-Ross process.
The discrete approximation is:
rt+1 rt = + rt + t+1
with
Et t+1 = 0, and Et (2t+1 ) = 2 rt2

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Discrete time approximations


Several continuous time processes for the term structure of
interest rate is embedded in the following process:
drt = ( + rt )dt + rt dWt

= 0 and = 0: Brownian motion with drift


= 0: Ornstein-Uhlenbeck process
= 1/2: Cox-Ingersoll-Ross process.
The discrete approximation is:
rt+1 rt = + rt + t+1
with
Et t+1 = 0, and Et (2t+1 ) = 2 rt2

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Discrete time approximations

Notice: Maximum likelihood cannot be used because the


distribution depends on : It is normal for = 0 and gamma for
= 1/2.
The moment conditions for the GMM approach are:

t+1

t+1 rt

E [g(, xt )] E 2 =0
2t+1 2 rt
(2t+1 2 rt2 )rt

Other moment conditions could be added by using variables


from the information set It

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Discrete time approximations

Notice: Maximum likelihood cannot be used because the


distribution depends on : It is normal for = 0 and gamma for
= 1/2.
The moment conditions for the GMM approach are:

t+1

t+1 rt

E [g(, xt )] E 2 =0
2t+1 2 rt
(2t+1 2 rt2 )rt

Other moment conditions could be added by using variables


from the information set It

Pierre Chauss GMM and GEL with R


Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Without discrete time approximation


The following approach is proposed by Hansen and
Scheinkman (1995). We want to estimate:
drt = (rt )dt + (rt )dWt
It is based on the assumption that rt is stationary which implies
E ((rt )) = c for some smooth functions ().
Then, after some manipulations (integrating, using Itos lemma
and Fubinis theorem), we can obtain the following moment
conditions:
 
1
E (rt ) (rt ) + (rt ) (rt ) = 0
2
For more efficiency, more moment conditions can be derived
using informations from the conditional distribution as well (see
Chan, Karolyi, Longstaff and Sanders (1992)).
Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Without discrete time approximation


The following approach is proposed by Hansen and
Scheinkman (1995). We want to estimate:
drt = (rt )dt + (rt )dWt
It is based on the assumption that rt is stationary which implies
E ((rt )) = c for some smooth functions ().
Then, after some manipulations (integrating, using Itos lemma
and Fubinis theorem), we can obtain the following moment
conditions:
 
1
E (rt ) (rt ) + (rt ) (rt ) = 0
2
For more efficiency, more moment conditions can be derived
using informations from the conditional distribution as well (see
Chan, Karolyi, Longstaff and Sanders (1992)).
Pierre Chauss GMM and GEL with R
Outline The generalized method of moments
GMM in finance Consumption-CAPM
GMM with R Linear factor pricing models
GEL in finance Nonlinear factor models
Whats next? Continuous time processes

Without discrete time approximation


The following approach is proposed by Hansen and
Scheinkman (1995). We want to estimate:
drt = (rt )dt + (rt )dWt
It is based on the assumption that rt is stationary which implies
E ((rt )) = c for some smooth functions ().
Then, after some manipulations (integrating, using Itos lemma
and Fubinis theorem), we can obtain the following moment
conditions:
 
1
E (rt ) (rt ) + (rt ) (rt ) = 0
2
For more efficiency, more moment conditions can be derived
using informations from the conditional distribution as well (see
Chan, Karolyi, Longstaff and Sanders (1992)).
Pierre Chauss GMM and GEL with R
Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

gmm()

gmm(g,x,t0=NULL,gradv=NULL,
type=c("twoStep","cue","iterative")
Other important options:
wmatrix = c("optimal","ident")
vcov=c("HAC","iid")
kernel=c("Quadratic Spectral","Truncated", "Bartlett",
"Parzen", "Tukey-Hanning")
bw = bwAndrews2 or bwNeweyWest2

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

gmm()

gmm(g,x,t0=NULL,gradv=NULL,
type=c("twoStep","cue","iterative")
Other important options:
wmatrix = c("optimal","ident")
vcov=c("HAC","iid")
kernel=c("Quadratic Spectral","Truncated", "Bartlett",
"Parzen", "Tukey-Hanning")
bw = bwAndrews2 or bwNeweyWest2

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

gmm()

gmm(g,x,t0=NULL,gradv=NULL,
type=c("twoStep","cue","iterative")
Other important options:
wmatrix = c("optimal","ident")
vcov=c("HAC","iid")
kernel=c("Quadratic Spectral","Truncated", "Bartlett",
"Parzen", "Tukey-Hanning")
bw = bwAndrews2 or bwNeweyWest2

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

gmm()

gmm(g,x,t0=NULL,gradv=NULL,
type=c("twoStep","cue","iterative")
Other important options:
wmatrix = c("optimal","ident")
vcov=c("HAC","iid")
kernel=c("Quadratic Spectral","Truncated", "Bartlett",
"Parzen", "Tukey-Hanning")
bw = bwAndrews2 or bwNeweyWest2

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

gmm()

gmm(g,x,t0=NULL,gradv=NULL,
type=c("twoStep","cue","iterative")
Other important options:
wmatrix = c("optimal","ident")
vcov=c("HAC","iid")
kernel=c("Quadratic Spectral","Truncated", "Bartlett",
"Parzen", "Tukey-Hanning")
bw = bwAndrews2 or bwNeweyWest2

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: estimation

> require(gmm)
> data(Finance)
> r <- Finance$r[1:300, ]
> rm <- Finance$rm[1:300]
> rf <- Finance$rf[1:300]
> z <- r - rf
> t <- nrow(z)
> zm <- matrix(rm - rf, t, 1)
> res <- gmm(z ~ zm, x = zm)

The model is zt = + zmt + t , the instruments are (1, zmt ).

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: the object of class gmm

The object "res" is a list:


> matrix(names(res), 3, 3)

[,1] [,2] [,3]


[1,] "par" "gt" "n"
[2,] "objective" "df" "met"
[3,] "vcov" "k" "kernel"

The parameters keep the names of the variables


> c(res$par)

WMK_(Intercept) UIS_(Intercept) ORB_(Intercept) MAT_(Intercept)


-0.004669736 0.102346762 0.145874663 0.035895010
ABAX_(Intercept) T_(Intercept) EMR_(Intercept) JCS_(Intercept)
0.091742457 0.023103455 0.029928596 0.116804715
VOXX_(Intercept) ZOOM_(Intercept) WMK_zm UIS_zm
0.020871224 -0.219135356 0.317193344 1.262716102
ORB_zm MAT_zm ABAX_zm T_zm
1.493908805 1.014990227 1.088976989 0.848978815
EMR_zm JCS_zm VOXX_zm ZOOM_zm
0.740787592 0.958818772 1.482166171 2.077703465

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: the object of class gmm

The object "res" is a list:


> matrix(names(res), 3, 3)

[,1] [,2] [,3]


[1,] "par" "gt" "n"
[2,] "objective" "df" "met"
[3,] "vcov" "k" "kernel"

The parameters keep the names of the variables


> c(res$par)

WMK_(Intercept) UIS_(Intercept) ORB_(Intercept) MAT_(Intercept)


-0.004669736 0.102346762 0.145874663 0.035895010
ABAX_(Intercept) T_(Intercept) EMR_(Intercept) JCS_(Intercept)
0.091742457 0.023103455 0.029928596 0.116804715
VOXX_(Intercept) ZOOM_(Intercept) WMK_zm UIS_zm
0.020871224 -0.219135356 0.317193344 1.262716102
ORB_zm MAT_zm ABAX_zm T_zm
1.493908805 1.014990227 1.088976989 0.848978815
EMR_zm JCS_zm VOXX_zm ZOOM_zm
0.740787592 0.958818772 1.482166171 2.077703465

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: the summary() method


The summary() method produces the following results:
> names(summary(res))
[1] "met" "kernel" "algo" "par" "J_test" "j"
The $par argument of summary() is more detailed:
> summary(res)$par
Estimate Std. Error t value Pr(>|t|)
WMK_(Intercept) -0.00467 0.05748 -0.08123 0.93526
UIS_(Intercept) 0.10235 0.11846 0.86401 0.38758
ORB_(Intercept) 0.14587 0.21227 0.68721 0.49195
MAT_(Intercept) 0.03590 0.10609 0.33833 0.73511
ABAX_(Intercept) 0.09174 0.27258 0.33657 0.73644
T_(Intercept) 0.02310 0.07582 0.30471 0.76059
EMR_(Intercept) 0.02993 0.05477 0.54641 0.58478
JCS_(Intercept) 0.11680 0.16275 0.71768 0.47296
VOXX_(Intercept) 0.02087 0.17444 0.11965 0.90476
ZOOM_(Intercept) -0.21914 0.19673 -1.11391 0.26532
WMK_zm 0.31719 0.13076 2.42575 0.01528
UIS_zm 1.26272 0.22784 5.54211 0.00000
ORB_zm 1.49391 0.42138 3.54524 0.00039
MAT_zm 1.01499 0.22899 4.43253 0.00001
ABAX_zm 1.08898 0.57801 1.88401 0.05956
T_zm 0.84898 0.16218 5.23482 0.00000
EMR_zm 0.74079 0.10460 7.08231 0.00000
JCS_zm 0.95882 0.35882 2.67213 0.00754
VOXX_zm 1.48217 0.38027 3.89762 0.00010
ZOOM_zm 2.07770 0.31617 6.57140 0.00000
Pierre Chauss GMM and GEL with R
Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: the summary() method

The J-test of overidentifying restrictions


> summary(res)$j
J-test Pz(>j)
Test E(g)=0: 1.53759618288292e-29 *******

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: testing the model

First, we can use the function lintest() to test the null:

H0 : R = c

where = {, } , R = {IN , ONN } and c = 0N1 .

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: testing the model

> R <- cbind(diag(10), matrix(0, 10, 10))


> c <- matrix(0, 10, 1)
> lintest(res, R, c)

[[1]]
[1] "Wald test for H0: R(Theta)=c"

$H0
Null Hypothesis
[1,] WMK_(Intercept) = 0
[2,] UIS_(Intercept) = 0
[3,] ORB_(Intercept) = 0
[4,] MAT_(Intercept) = 0
[5,] ABAX_(Intercept) = 0
[6,] T_(Intercept) = 0
[7,] EMR_(Intercept) = 0
[8,] JCS_(Intercept) = 0
[9,] VOXX_(Intercept) = 0
[10,] ZOOM_(Intercept) = 0

$result
Statistics P-Value
Wald test 4.118292 0.9418528

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM: testing the model

Second, we use the J-test on the constraint model


> h <- cbind(1, zm)
> res_c <- gmm(z ~ zm, x = h, intercept = FALSE)
> summary(res_c)$j
J-test Pz(>j)
Test E(g)=0: 3.984548 0.9480414

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The APT of Fama-French

Using the three-factor model of Fama and French:


> hml <- Finance$hml[1:300]
> smb <- Finance$smb[1:300]
> h <- cbind(1, zm, hml, smb)
> res_apt <- gmm(z ~ zm + hml + smb, x = h, intercept = FALSE)
> summary(res_apt)$j

J-test Pz(>j)
Test E(g)=0: 2.818007 0.9853883

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The Black-CAPM

The moment function is like the CAPM but with:

t = rt (rmt )

where is the expected return of the zero-beta portfolio (here,


= {, } ).
> g <- function(theta, x) {
+ e <- x[, 2:11] - theta[1] - (x[, 1] - theta[1]) %*% matrix(theta[2:11],
+ 1, 10)
+ gmat <- cbind(e, e * c(x[, 1]))
+ return(gmat)
+ }
> x <- cbind(rm, r)
> res <- gmm(g, x = x, rep(0, 11))

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The Black-CAPM

> summary(res)$par

Estimate Std. Error t value Pr(>|t|)


Theta[1] 0.09463 0.07084 1.33595 0.18156
Theta[2] 0.40077 0.12702 3.15521 0.00160
Theta[3] 1.02717 0.23039 4.45845 0.00001
Theta[4] 1.00463 0.42721 2.35158 0.01869
Theta[5] 0.83611 0.22523 3.71217 0.00021
Theta[6] 0.65384 0.54010 1.21060 0.22605
Theta[7] 0.79805 0.15163 5.26318 0.00000
Theta[8] 0.80353 0.10048 7.99680 0.00000
Theta[9] 0.92048 0.34594 2.66083 0.00779
Theta[10] 1.32823 0.36145 3.67476 0.00024
Theta[11] 2.11812 0.30396 6.96839 0.00000

> summary(res)$j

J-test Pz(>j)
Test E(g)=0: 5.801583 0.7596007

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM (SDF): testing the model

Here we need to compute a T q matrix with typical


element (t, i) equals to gi (, xt ) = (0 + 1 Rmt )Rit 1:
> g <- function(tet, x) {
+ gmat <- (tet[1] + tet[2] * (1 + c(x[, 1]))) * (1 + x[, 2:11]) -
+ 1
+ return(gmat)
+ }
> res_sdf <- gmm(g, x = cbind(rm, r), c(0, 0))
> summary(res_sdf)$j

J-test Pz(>j)
Test E(g)=0: 3.824509 0.8725995

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

The CAPM (SDF): testing the model

To improve precision, we can provide the derivative of g():


P P 
Dg = T1 t Rt , T1 t Rt Rmt

> Dg <- function(tet, x) {


+ G <- cbind(colMeans(1 + x[, 2:11]), colMeans(c(1 + x[, 1]) *
+ (1 + x[, 2:11])))
+ return(G)
+ }
> res_sdf <- gmm(g, x = cbind(rm, r), c(0, 0), gradv = Dg)

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

Discrete time approximation of continuous time


processes

As shown above, we need to write a function which returns


a T 4 matrix with the t th row equals:

t+1

t+1 rt

g(, xt ) = 2
2t+1 2 rt


(2t+1 2 rt2 )rt

where
t+1 = rt+1 rt rt

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

Discrete time approximation of continuous time


processes
In the function, = {, , 2 , }
> g <- function(theta, x) {
+ t <- length(x)
+ et1 <- diff(x) - theta[1] - theta[2] * x[-t]
+ ht <- et1^2 - theta[3] * x[-t]^(2 * theta[4])
+ g <- cbind(et1, et1 * x[-t], ht, ht * x[-t])
+ return(g)
+ }

> rf <- Finance$rf


> rf <- ((1 + rf/100)^(365) - 1) * 100
> dr <- diff(rf)
> res_0 <- lm(dr ~ rf[-length(rf)])
> tet0 <- c(res_0$coef, var(residuals(res_0)), 0)
> res_rf <- gmm(g, rf, tet0, control = list(maxit = 1000, reltol = 1e-10))
> summary(res_rf)$par

Estimate Std. Error t value Pr(>|t|)


Theta[1] 0.01067 0.00469 2.27769 0.02274
Theta[2] -0.00207 0.00104 -1.98885 0.04672
Theta[3] 0.00649 0.00335 1.93711 0.05273
Theta[4] 0.45948 0.15987 2.87410 0.00405

Pierre Chauss GMM and GEL with R


Outline
GMM in finance The function gmm()
GMM with R Linear models
GEL in finance Nonlinear models
Whats next?

Discrete time approximation of continuous time


processes
In the function, = {, , 2 , }
> g <- function(theta, x) {
+ t <- length(x)
+ et1 <- diff(x) - theta[1] - theta[2] * x[-t]
+ ht <- et1^2 - theta[3] * x[-t]^(2 * theta[4])
+ g <- cbind(et1, et1 * x[-t], ht, ht * x[-t])
+ return(g)
+ }

> rf <- Finance$rf


> rf <- ((1 + rf/100)^(365) - 1) * 100
> dr <- diff(rf)
> res_0 <- lm(dr ~ rf[-length(rf)])
> tet0 <- c(res_0$coef, var(residuals(res_0)), 0)
> res_rf <- gmm(g, rf, tet0, control = list(maxit = 1000, reltol = 1e-10))
> summary(res_rf)$par

Estimate Std. Error t value Pr(>|t|)


Theta[1] 0.01067 0.00469 2.27769 0.02274
Theta[2] -0.00207 0.00104 -1.98885 0.04672
Theta[3] 0.00649 0.00335 1.93711 0.05273
Theta[4] 0.45948 0.15987 2.87410 0.00405

Pierre Chauss GMM and GEL with R


Outline
GMM in finance
The generalized empirical likelihood
GMM with R
GEL with R
GEL in finance
Whats next?

GEL
First of all, we need to smooth the moment function in order to
take into account the autocorrelation and conditional
heteroskedasticity. g(, xt ) is replaced by:
m
X
g w (, xt ) = w (s)g(, xts )
s=m

where w (s) are kernel based weights that sum to one. The
sample moment conditions become:
T
X
g() = pt g w (, xt ) = 0
t=1

where pt are probabilities implied by the moment conditions.


Pierre Chauss GMM and GEL with R
Outline
GMM in finance
The generalized empirical likelihood
GMM with R
GEL with R
GEL in finance
Whats next?

GEL
The GEL estimator is defined as:
T
X
n = arg min hT (pt ),
,pt
t=1
subject to
XT
pt g w (, xt ) = 0 and
t=1
T
X
pt = 1,
t=1

where h() is a discrepancy function which measure the


distance between the empirical density 1/T and pt .
Pierre Chauss GMM and GEL with R
Outline
GMM in finance
The generalized empirical likelihood
GMM with R
GEL with R
GEL in finance
Whats next?

GEL

It can be shown that it is equivalent to the following saddle point


problem which is how it is computed numerically:
" T
#
1X 
= arg min max g w (, xt ) (1)
T
t=1

for some (), where is the Lagrange multiplier associated with


the moment conditions. The popular functions are:
(v) = ev : Exponential tilting
(v) = log (1 v): Empirical likelihood
(v) = 0.5v 2 : continuous updated GMM

Pierre Chauss GMM and GEL with R


Outline
GMM in finance
The generalized empirical likelihood
GMM with R
GEL with R
GEL in finance
Whats next?

GEL

It can be shown that it is equivalent to the following saddle point


problem which is how it is computed numerically:
" T
#
1X 
= arg min max g w (, xt ) (1)
T
t=1

for some (), where is the Lagrange multiplier associated with


the moment conditions. The popular functions are:
(v) = ev : Exponential tilting
(v) = log (1 v): Empirical likelihood
(v) = 0.5v 2 : continuous updated GMM

Pierre Chauss GMM and GEL with R


Outline
GMM in finance
The generalized empirical likelihood
GMM with R
GEL with R
GEL in finance
Whats next?

The function gel()

gel(g,x,tet0,gradv=NULL,smooth=FALSE,
type=c("EL","ET","CUE","ETEL"))
Other options:
kernel = c("Bartlett", "Parzen", "Truncated",
"Tukey-Hanning")
bw=bwAndrews2
tol_obj
maxiterlam
constraint=TRUE
optlam=c("iter","numeric")

Pierre Chauss GMM and GEL with R


Outline
GMM in finance
The generalized empirical likelihood
GMM with R
GEL with R
GEL in finance
Whats next?

CAPM

I choose the truncated kernel which corresponds to the HAC


computed with the Parzen kernel.
> rf <- Finance$rf[1:300]
> zm <- matrix(rm - rf, t, 1)
> res1 <- gmm(z ~ zm, x = zm)
> x <- cbind(1, zm)
> res <- gel(z ~ zm, x = x, res1$par[11:20], smooth = TRUE, kernel = "Truncated",
+ intercept = FALSE)
> summary(res)$test

statistics p-value
LR test 12.09362 0.2788400
LM test 11.53989 0.3170287
J test 12.19297 0.2723491

Pierre Chauss GMM and GEL with R


Outline
GMM in finance
GMM with R
GEL in finance
Whats next?

Some ideas

Add more flexibility to the optimization algorithm: ex. allow


constraints on parameters.
Simplify the method for nonlinear models. Make it as
simple as "nls()"
Add a procedure for simulated method of moments
any more suggestions are welcome.

Pierre Chauss GMM and GEL with R

Você também pode gostar