# RE: st: endogenous switching model

 From aylakayhan@mail.utexas.edu To statalist@hsphsun2.harvard.edu Subject RE: st: endogenous switching model Date Mon, 30 Jun 2003 15:02:03 -0500

```Dear Renzo,

Thank you very much for taking time to respond to my problem.  I may have not
written the lf in the right way, but the potential problem that you are
pointing at does not apply to my case.  What I would like to estimate is an
endogenous selection, i.e., I don't know the sample selection a priori.  Your
example applies to the case where the selection is observed, that is, we know
who is a union worker and who is not a union worker.  But in my sample I don't
know which managers are entrenched and which are not entrenched.

Thank you very much,

Ayla

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
statalist@hsphsun2.harvard.edu] On Behalf Of Renzo Comolli
Sent: Wednesday, June 25, 2003 12:18 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: endogenous switching model

Dear Ayla,

Unfortunately I cannot fix the code for you, but, by looking at your code, it
seems quite plausible that you haven't understood how -lf- works. I suggest you
consult
Maximum Likelihood Estimation with Stata
It is very quick to read and master the book if you care only about -lf-

I try now to explain where (I think) your problem lies, but I realize my
explanation is quite obscure (the book does a much better job).
-lf- is written for all those cases in which data are independent.
Assuming that this is true in your case, -lf- does the sum for you in the log
likelihood, but you have to tell to the procedure which summand it has to use
for each element of the dependent variable vector. Let's make an
example: you have union members and union non members, your loglikelihood is
just sum l(i) but the l(i) is different for members and nonmembers, then you
would just write

quietly replace `lnf' = l(i) if \$ML_y1="member"
quietly replace `lnf' = l(i) if \$ML_y1="non member"

Of course l(i) contains the theta(s) and it is different for members and non
members

I hope it helps
Renzo Comolli

-----Original Message-----
From: "Ayla Kayhan" <akayhan@mail.utexas.edu>
Subject: st: endogenous switching model
Date: Tue, 24 Jun 2003 17:49:10 -0500

Hi,

I would to estimate an endogenous switching model where the sample separation
is not known (Maddala 1983, 1986). Specifically, I would like to estimate two
sets of parameters for the two regimes where the observations are endogeneously
assigned to one of the two groups (I do not observe the sample separation). I
have specified the maximum likelihood function but the code I have written is
not converging.  I have tried various starting values including the OLS
parameter estimates that I have obtained from the entire sample, but the ml
procedure failed to converge.

Any ideas as to how I can get this procedure to converge is greatly appreciated.

Thank you very much,

Ayla

Note:  The following is the program I defined for ml

program define maxim;
version 7.0;

args lnf theta1 theta2 theta3 theta4 theta5 theta6 theta7;

quietly replace
`lnf' = ln(
norm(
(-`theta1'-(`theta3'*(\$ML_y1-`theta6')/`theta2'^2))
/sqrt(1-(`theta3'^2/`theta2'^2))
)
*normd(\$ML_y1-`theta4')/`theta2'
+ (1-norm(
(-`theta1'-(`theta5'*(\$ML_y1-`theta7')/`theta6'^2))
/sqrt(1-(`theta5'^2/`theta6'^2))
))
*normd(\$ML_y1-`theta7')/`theta6'
);
end;

ml model lf ayla (d5bl = lceoownp lmeddpay loffcc)
()
()
(led5 lcov5 lmbbfd5 lmtob lebitda lppe lsize)
()
()
(led5 lcov5 lmbbfd5 lmtob lebitda lppe lsize pl5bl), robust cluster(gvkey);

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```