next up previous
Next: About this document

Spring 1997 John Rust
Economics 551b 37 Hillhouse, Rm. 27

HINTS TO MIDTERM EXAM

(Due: March 24, 1997)

=50000 =50000 `^Z=9

Hint for Problem 1: Use the TCP/IP ftp command to get the data set stockdat.dat and its Gauss header file stockdat.dht by anonymous ftp from gemini.econ.yale.edu as follows:

1.
ftp gemini.econ.yale.edu
2.
login: anonymous
3.
password: econ551
4.
ftp>cd /pub/John_Rust/courses/econ161/stats/stocks/dat
5.
ftp>bin (to change to binary transfer mode)
6.
ftp>get stockdat.dat
7.
ftp>get stockdat.dht
8.
ftp>quit

If you are using Gauss under a Unix system you must do transdat stockdat.dat to translate the data set into Gauss's Unix system format. Otherwise you are ready to use the data in the Dos/Windows version of Gauss. Get into Gauss and open up the data set by typing open f1=stockdat and then load the data set into memory by typing dat=readr(f1,rowsf(f1)). To find out the names of the columns of the data set, do nms=getname("stockdat") and the tex2html_wrap_inline103 column vector nms will contain the names of each of the 66 columns in the tex2html_wrap_inline105 data matrix dat. You can use the loc procedure (available on the Econ 551 web page along with the other programs) to extract specific columns of the dat matrix by name, e.g. dat[.,loc("VALAV",nms)] will return the column of the market portfolio returns, where the portfolio is a value-weighted portfolio suggested by the CAPM model as a preferable means of forming an index of returns on the market portfolio.

Hints on Problem 2: In part 6 of problem 2 you are required to compute the posterior probability of being within a ball of radius .01 about tex2html_wrap_inline109 . I suggest computing this probability by monte carlo simulations, drawing say 10,000 draws from the Dirichlet posterior and computing the fraction that lie in the ball of radius .01 about tex2html_wrap_inline109 . How do you draw from a Dirichlet distribution? Use the following result:

Lemma: Let tex2html_wrap_inline115 be independent random variables, where each tex2html_wrap_inline117 has a gamma distribution with parameter tex2html_wrap_inline119 . Then the random vector tex2html_wrap_inline121 has a Dirichlet distribution with parameter tex2html_wrap_inline123 where each tex2html_wrap_inline125 is defined by:

displaymath127

Hints on Problem 4: Load the data sets data1.asc and data2.asc by anonymous ftp following the same instructions as above, but cd /pub/John_Rust/courses/econ551/dat and get data1.asc and get data2.asc (there is no need to switch to binary mode since these two data sets are in ASCII format). You will use data1.asc to estimate a trinomial logit model with 6 unknown alternative-specific coefficients by maximum likelihood.

To compute the maximum likelihood estimates you first need to write down the likelihood function and derivatives. Only first derivatives are required if you use BHHH but second derivatives are required if you use Newton's method. There are two ways to write down these formulae: 1) write down formulae that are specific to the case at hand, 2) write down formulae that will be useful for estimating any type of multinomial logit model with any number of alternatives.

1.
Alternative-specific trinomial code: You will need to write a procedure EVALMNL1.G that codes the likelihood and first and second derivatives of the trinomial logit model with alternative-specific coefficients. This procedure will then be passed in the setup program that reads in the data and runs the main maximization procedure, MAX.G. Partition the unknown tex2html_wrap_inline129 parameter vector tex2html_wrap_inline131 into two components, tex2html_wrap_inline133 where tex2html_wrap_inline135 is the tex2html_wrap_inline137 parameter vector for alternative 2 and tex2html_wrap_inline139 is the tex2html_wrap_inline137 parameter vector for alternative 3 with tex2html_wrap_inline143 normalized to 0 since it is unidentified. Next write down the log-likelihood function for this model as follows:

eqnarray58

2.
General multinomial logit code: you can write a general multinomial logit procedure EVALMNL.G that codes the likelihood and first and second derivatives for a general multinomial logit model with fixed coefficients and alternative-specific covariates. This procedure is then passed in the setup program that reads in the data and runs the main maximization procedure, MAX.G. This code will estimate an arbitrary MNL model with an arbitrary number of alternatives. The general model has a covariate vector tex2html_wrap_inline145 which is alternative-specific (with tex2html_wrap_inline147 being the covariate vector for alternative j) and the parameter vector tex2html_wrap_inline131 is not alternative-specific. The likelihood function for the general MNL model has the following form:

displaymath153

You can ``trick'' the general MNL code into estimating the alternative-specific trinomial model of this assignment by defining an tex2html_wrap_inline155 covariate vector tex2html_wrap_inline157 as follows:

eqnarray65

where tex2html_wrap_inline159 is the original non-alternative-specific covariate vector (dependence on observation i, tex2html_wrap_inline163 is supressed for clarity). It is straightforward to verify that when the alternative-specific covariate vector tex2html_wrap_inline165 defined above is substituted into the general formula for the MNL log-likelihood we obtain the special case for the trinomial logit model with alternative-specific coefficients. We now complete the assignment by specifying the first and second derivatives of the log-likelihood function. We will do this for both the alternative-specific and general forms of the MNL model.

First derivatives for trinomial logit model with alternative-specific tex2html_wrap_inline131 's

eqnarray75

First derivatives for general MNL model

displaymath169

Second derivatives for trinomial logit model with alternative-specific tex2html_wrap_inline131 's

eqnarray80

Second derivatives for general MNL model

displaymath173




next up previous
Next: About this document

John Rust
Tue Mar 4 14:46:48 CST 1997