{smcl}
{* 12apr2004}{...}
{hline}
help for {hi:movestay}{right:(SJ4-3: st0071)}
{hline}

{title:Maximum likelihood estimation of endogenous switching regression model}

{p 8 16 2} {cmd:movestay} ({it:depvar1} [{cmd:=}] {it:varlist1})
                        [({it:depvar2} [{cmd:=}] {it:varlist2})]
 [{it:weight}] [{cmd:if} {it:exp}] [{cmd:in} {it:range}]{cmd:,}
{cmdab:sel:ect:(}{it:depvar_s} [{cmd:=}] [{it:varlist_s}]{cmdab:)}
{bind:[{cmdab:r:obust}} {cmdab:cl:uster:(}{it:varname}{cmd:)}
{it:maximize_options}]

{p 4 4 2}
{cmd:pweight}s, {cmd:fweight}s and {cmd:iweight}s are allowed; see help {help weights}.

{p 4 4 2}
{cmd:movestay} shares the features and options of all maximum
likelihood estimation commands.

{p 4 4 2}
The syntax of {cmd:mspredict} following {cmd:movestay} is

{p 8 4 2} {cmd:mspredict} {it:newvarname} [{cmd:if} {it:exp}]
[{cmd:in} {it:range}] [{cmd:,} {it:statistic}]

{p 4} where {it:statistic} is {p_end}

{p 8 16 2}{cmdab:ps:el}{space 3}  probability of being in regime 1; default

{p 8 16 2}{cmd:xb1}{space 4}   linear prediction in regime 1

{p 8 16 2}{cmd:xb2}{space 4}   linear prediction in regime 2 

{p 8 16 2}{cmd:yc1_1}{space 2} expected value of the dependent variable in the first equation conditional on the dependent variable being observed

{p 8 16 2}{cmd:yc1_2}{space 2} expected value of the dependent variable in the first equation conditional on the dependent variable not being observed

{p 8 16 2}{cmd:yc2_1}{space 2} expected value of the dependent variable in the second equation conditional on the dependent variable being observed

{p 8 16 2}{cmd:yc2_2}{space 2} expected value of the dependent variable in the second equation conditional on the dependent variable not being observed 

{p 8 16 2}{cmd:mills1} and {cmd:mills2} Mill's ratios for the two regimes


{title:Description}

{p 4 4 2}
{cmd:movestay} uses the maximum likelihood method to estimate the
endogenous switching regression model.

{p 4 4 2}
It is implemented as {cmd:d2} evaluator that calculates the overall log
likelihood along with its first and second derivatives.

{p 4 4 2}
{cmd:movestay} estimates all of the parameters in the model:

{p 8 8 2}(regression equation for regime 1: y1 is {it:depvar1}, x1 is {it:varlist1}){p_end}
{p 16}y1 = x1*b1 + e_1{p_end}

{p 8 8 2}(regression equation for regime 2: y2 is {it:depvar2}, x2 is {it:varlist2}){p_end}
{p 16}y2 = x1*b2 + e_1{p_end}

{p 8}(selection equation: Z is {it:varlist_s}){p_end}
{p 16}y1 observed if Zg + u > 0{p_end}
{p 16}y2 observed if Zg + u <=0{p_end}

{p 8}where:{p_end}
{p 16} e_1 ~ N(0, sigma1){p_end}
{p 16}e_2 ~ N(0, sigma1){p_end}
{p 16}u   ~ N(0, 1){p_end}
{p 16}corr(e_1, u) = rho_1{p_end}
{p 16}corr(e_2, u) = rho_2{p_end}

{p 4 4 2}In the syntax for {cmd:movestay}, {it:depvar1,2} and {it:varlist1,2}
are the dependent variables and regressors for the underlying regression
models (y1,2 = xb), and {it:varlist_s} are the variables (Z) thought to
determine which regime is observed.{p_end}


{title:Options}

{p 4 8 2}
{cmd:select(}{it:depvar_s} {cmd:=} {it:varlist_s}{cmd:)} gives the
specification of switching equation for I_i. {it:varlist_s} includes the set
of instruments that help identify the model.  It is an integral part of the
{cmd:movestay} estimation and is not optional. The selection equation is
estimated based on all exogenous variables specified in the continuous
equations plus instruments.  If there are no instrumental variables in the
model, the {it:depvar_s} must be specified.  In that case, the model will be
identified by nonlinearities and the selection equation will contain all the
independent variables that enter in the continuous equations.

{p 4 8 2}
{cmd:robust} specifies that the Huber/White/sandwich estimator of the
variance is to be used in place of the conventional MLE variance estimator.
{cmd:robust} combined with {cmd:cluster()} further allows observations which
are not independent within cluster (although they must be independent between
clusters).

{p 8 8 2}
If you specify {cmd:pweight}s, {cmd:robust} is implied.
See {hi:[U] 23.14 Obtaining robust variance estimates}.

{p 4 8 2}
{cmd:cluster(}{it:varname}{cmd:)} specifies that the observations are
independent across groups (clusters) but not necessarily within groups.
{it:varname} specifies to which group each observation belongs; e.g.,
{cmd:cluster(personid)} in data with repeated observations on individuals.
{cmd:cluster()} affects the estimated standard errors and variance-covariance
matrix of the estimators (VCE), but not the estimated coefficients.
{cmd:cluster()} can be used with {help pweight}s to produce estimates for
unstratified cluster-sampled data.  Specifying {cmd:cluster()} implies
{cmd:robust}.

{p 4 8 2}
{it:maximize_options} control the maximization process; see
{help maximize}.  With the possible exception of {cmd:iterate(0)} and
{cmd:trace}, you should only have to specify them if the model is unstable.


{title:Options for {help predict}}

{p 4 8 2}{cmd:psel} calculates the probability of being in regime 1. This is
the default.

{p 4 8 2}{cmd:xb1} calculates the linear prediction for the regression
equation in regime 1.

{p 4 8 2}{cmd:xb2} calculates the linear prediction for the regression
equation in regime 2.

{p 4 8 2}{cmd:yc1_1} calculates the expected value of the dependent variable
in the first equation conditional on the dependent variable being observed.

{p 4 8 2}{cmd:yc1_2} calculates the expected value of the dependent variable
in the first equation conditional on the dependent variable not being
observed.

{p 4 8 2}{cmd:yc2_1} calculates the expected value of the dependent variable
in the second equation conditional on the dependent variable being observed.

{p 4 8 2}{cmd:yc2_2} calculates the expected value of the dependent variable
in the second equation conditional on the dependent variable not being
observed. 

{p 4 8 2}{cmd:mills1} and {cmd:mills2} calculate corresponding Mill's ratios
for the two regimes. 


{title:Example}

{p 4}To obtain full ML estimates:

{p 6} Using instruments:

{p 8 12 2}{cmd:. movestay y1 x1 x2 x3 x4, select(regime1=z1 z2) }

{p 8 12 2}{cmd:. movestay (y1= x1 x2 x3 x4) (y1= x1 x2 x3 x5), select(regime1=z1 z2) }

{p 6}Model is identified through non-linearities:

{p 8 12 2}{cmd:. movestay (y1= x1 x2 x3 x4) (y1= x1 x2 x3 x5), select(regime1)}

{p 4}To define and use each equation separately:

{p 8 8 2}{cmd:. global wage_eqn y x1 x2 x3 x4}
{break}{cmd:. global select_eqn regime z1 z2}

{p 8 12 2}{cmd:. movestay ($wage_eqn), select($select_equn)}

{p 4}To use options:

{p 8 12 2}{cmd:. movestay y= x1 x2 x3 x4 if region=1 [w= hhweight], select(regime= z1 z2)}

{p 8 12 2}{cmd:. movestay (y= x1 x2 x3 x4) if region=1, select(regime= z1 z2) tech("dfp")}

{p 4}Prediction:

{p 8 12 2} {cmd:. movestay y x1 x2 x3 x4, select(regime= z1 z2)}

{p 8 12 2} {cmd:. mspredict yexpected, xb}

{p 8 12 2} {cmd:. mspredict mymills1, mills1}

{p 4}Example from the STATA Journal:

{p 8 12 2}{stata `"do  http://www.worldbank.org/research/projects/poverty/programs/movestay_example.do"': . movestay lmo_wage age age2 edu13 edu4 edu5 reg2 reg3 reg4, select(private =m_s1 job_hold)}


{title:Also see}

{p 4 14 2}
Online:  help for {help regress}, {help heckman}, {help ml}
