Consider the following sequential, adaptive data generating process for $Y_1$, $Y_2$, $Y_3$. (By sequential I mean that we generate $Y_1$, $Y_2$, $Y_3$ in sequence and by adaptive I mean that $Y_3$ is generated depending on the observed values of $Y_1$ and $Y_2$.):
$Y_1 = X_1\ \beta + \epsilon_1$
$Y_2 = X_2\ \beta + \epsilon_2$
$Y_3 = X_3\ \beta + \epsilon_3$
$ X_3 = \begin{cases} X_{31} & \mbox{if }Y_1 Y_2 \gt 0 \\ X_{32} & \mbox{if }Y_1 Y_2 \le 0 \end{cases}$
where,
$X_1$, $X_2$, $X_{31}$ and $X_{32}$ are all 1 x 2 vectors.
$\beta$ is a 2 x 1 vector
$\epsilon_i \sim N(0,\sigma^2)$ for $i$ = 1, 2, 3
Suppose we observe the following sequence: {$Y_1 = y_1,\ Y_2 = y_2,\ X_3 = X_{31},\ Y_3 = y_3$} and wish to estimate the parameters $\beta$ and $\sigma$.
In order to write down the likelihood function note that we have four random variables: $Y_1$, $Y_2$, $X_3$ and $Y_3$. Therefore, the joint density of $Y_1$, $Y_2$, $X_3$ and $Y_3$ is given by:
$f(Y_1, Y_2, X_3, Y_3 |-) = f(Y_1|-)\ f(Y_2|-)\ [\ f(Y_3|X_{31},-)\ P(X_3=X_{31}|-)$
$\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad + \ f(Y_3|X_{32},-)\ P(X_3={X_{32}}|-)\ ]$
(Note: I am suppressing the dependency of the density on $\beta$ and $\sigma$.)
Since the likelihood conditions on the observed data and our sequence is such that $y_1 y_2 >0$. Therefore, we have:
$L(\beta,\ \sigma | X_1,\ X_2,\ X_{31}, y_1, y_2, y_3) = f(Y_1|-)\ f(Y_2|-)\ f(Y_3|X_{31},-)\ P(X_3=X_{31}) $
Is the above the correct likelihood function for this data generating process?