This is a model that is used to model soccer scores, so $i$ and $j$ are, respectively, home and away teams. Random variables $(x,y)$ are the goals scored by the home and away teams, respectively. Parameter $\lambda$ is a known mean goals scored by the home team and $\mu$ is the mean goals scored by the away team. I have managed to fix all the other parameters except for $\rho$, which I have to estimate via MLE.
$$Pr(X_{i,j}=x, Y_{i,j}=y)=\tau_{\lambda, \mu}(x,y)\frac{\lambda^x \text{exp}(-\lambda)}{x!}\frac{\mu^y\text{exp}(-\mu)}{y!}$$ where $$\lambda=\alpha_{i}\beta_{j}\gamma$$ $$\mu=\alpha_{j}\beta_{i}$$ and $$\tau_{\lambda,\mu}(x,y)=\left\{\begin{array}{cc} 1-\lambda\mu\rho &\text{if $x=y=0$,} \\ 1+\lambda\rho &\text{if $x=0,y=1$,}\\ 1+\mu\rho &\text{if $x=1,y=0$,}\\ 1-\rho &\text{if $x=y=1$,}\\ 1 &\text{otherwise}\end{array} \right.$$
Based on the above equations, all the parameters $(\lambda, \mu, \alpha, \beta, \gamma)$ are known constants.
So, now, the problem that I am having is that I have no clue on how to estimate $\rho$ using the maximum likelihood function since a piece-wise equation is involved.
Also, it will be great if anyone can do this using R.