MicroEconometrics Lecture10
MicroEconometrics Lecture10
618 Microeconometrics
Michael T. Sandfort
Department of Applied Economics
The Johns Hopkins University
November 19, 2013
Limited Dependent Variable Models
i
y
i
_
=
1
n
nE(y) = E(y)
= 1 Pr (y = 1) + 0 Pr (y = 0)
= Pr (y = 1)
1
.
0
0
.
5
0
.
0
0
.
5
1
.
0
1
.
5
2
.
0
exper
i
n
l
f
10 0 10 20 30 40 50
0
.
0
0
.
5
1
.
0
1
.
5
exper
P
r
Note that the predicted probability Pr (y = 1|exper) > 1 for
exper > 10 and that Pr exceeds one (100%) for exper > 30.
Economics 440.618 Microeconometrics 7
Concerns About LPM
Some of the problems are fairly evident, but worth highlighting
(
w
)
Economics 440.618 Microeconometrics 11
The Probit Model
The second is the standard
normal CDF, which has the form
G(x) =
_
x
(w)dw
= (x)
where
(w) =
1
2
exp
_
w
2
2
_
3 2 1 0 1 2 3
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
The Probit (Normal) CDF (w)
w
(
w
)
Economics 440.618 Microeconometrics 12
How to estimate?
).
i =1
ln f (y
i
, )
rather than the log likelihood function itself.
The value
which maximizes L(, y) (or ln L(, y)) is known
as the maximum likelihood estimate of .
Economics 440.618 Microeconometrics 16
ML Estimation: Example 1 (Exponential)
y
1
__
1
y
2
_
_
1
y
n
i =1
y
i
Economics 440.618 Microeconometrics 17
ML Estimation: Example 1 (Exponential)
i
y
i
i
y
i
2
= 0
or
=
1
n
i
y
i
.
6
0
0
5
0
0
4
0
0
3
0
0
l
n
L
(
,
y
)
Economics 440.618 Microeconometrics 20
ML Estimation: Example 1 (Exponential)
The optim function can be used to perform numerical
optimization. Heres an example of using it to solve the last
problem:
> sol = optim(1,fn=LL.exp,gr=NULL,y.data,method="BFGS",control=list(fnscale=-1))
> sol$par
[1] 0.4983282
Heres what the arguments mean:
gr A function providing the gradient is often used to speed up
calculation. The argument gr references that function if it exists
(otherwise NULL).
y.data This is a reference to our data set. All unnamed arguments after gr
are passed through to the function to be optimized: LL.exp.
method There are several options. This is a safe one.
control This is a list of control parameters. By setting fnscale to -1, we
are saying we want to maximize rather than minimize (the default).
Economics 440.618 Microeconometrics 21
ML Estimation: Example 1 (Exponential)
Note that our data doesnt have to be drawn from an exponential
to t it with an exponential density. We could do the same thing
with data from a U(.25, 1).
0.4 0.6 0.8 1.0
1
0
0
0
8
0
0
6
0
0
l
n
L
(
,
y
)
> sol = optim(1,fn=LL.exp,gr=NULL,y.data,method="BFGS",control=list(fnscale=-1))
> sol$par
[1] 0.6135531
Economics 440.618 Microeconometrics 22
ML Estimation: Example 2 (Normal)
Similarly, we can estimate parameters of a normal via ML. We
dont need to do much algebra to know that, since the population
parameters are = (,
2
), the ML estimates of the parameters
should end up looking like the sample mean and variance. Lets
check.
i =1
_
1
2
2
exp
_
(y
i
1
)
2
2
2
__
or
L(
1
,
2
, y) =
_
1
2
2
_
n
exp
_
i
(y
i
1
)
2
2
2
_
i
(y
i
1
)
2
2
2
Economics 440.618 Microeconometrics 23
ML Estimation: Example 2 (Normal)
1
=
1
2
n
i =1
(y
i
1
)
2
=
n
2
2
+
1
2
2
2
n
i =1
(y
i
1
)
2
1
= y and
2
=
1
n
n
i =1
(y
i
y)
2
Economics 440.618 Microeconometrics 24
ML Estimation: Example 2 (Normal)
Now lets solve this as we usually would, numerically. We start
with a data set consisting of 1000 draws from a N(0, 1). Below are
the log-likelihood function and a plot of contours of the
log-likelihood function. The plot clearly shows a maximum
= (
1
,
2
) somewhere in the vicinity of (0, 1) so far so good.
> LL.norm = function(theta,y) {
+ n = length(y)
+ LL = -(n/2) * log(2*pi) - (n/2)*log(theta[2]) -
+ (1/(2*theta[2])) * sum( (y-theta[1])^2 )
+ return(LL)
+ }
Economics 440.618 Microeconometrics 25
ML Estimation: Example 2 (Normal)
t1
t
2
1456
1452
1450
1448 1448
1446
1444
1442
1440
1438
1
4
3
8
1436
1
4
3
6
1434
1434
1432
1432
1430
1428
1426
1424
0.10 0.05 0.00 0.05 0.10
0
.
8
0
.
9
1
.
0
1
.
1
1
.
2
Economics 440.618 Microeconometrics 26
ML Estimation: Example 2 (Normal)
> sol = optim(c(.5,.75),fn=LL.norm,gr=NULL,y.data,
+ method="BFGS",control=list(fnscale=-1))
> sol$par
[1] 0.0295824 1.0092104
Economics 440.618 Microeconometrics 27