# MLE of $(\theta_1,\theta_2)$ in a piecewise PDF

I am trying to find the MLE of $$\theta=(\theta_1,\theta_2)$$ in a random sample $$\{X\}_{i=1}^n$$ with the following pdf

$$f(x\mid\theta)= \begin{cases} (\theta_1+\theta_2)^{-1}\exp\left(\frac{-x}{\theta_1}\right) &, x>0\\ (\theta_1+\theta_2)^{-1}\exp\left(\frac{x}{\theta_2}\right) &, x\le0\\ \end{cases}$$

If I let $$\bar{X}_1$$ be the average of the $$n_1$$ values where $$X_1>0$$ and $$\bar{X}_2$$ the average of $$n_2$$ values where $$X_i\le 0$$ and $$n_1+n_2=n$$ Then the likelihood function is: $$L(\theta\mid X)=\left(\frac 1 {\theta_1+\theta_2}\right)^n\exp\left(\frac{-n_1\bar{X}_1}{\theta_1}+\frac{n_2\bar{X}_2}{\theta_2}\right)$$

but I am having trouble maximizing this function.

• The whole point of using the $\exp(x)$ notation rather than $e^x$ is that the exponent $x$ is NOT a superscript, so that when that is a lengthy expression, such as $\displaystyle \exp\left( \sum_{n=1}^\infty \frac 1 {n^2} \right)$ then it doesn't get typographically unpleasant. I edited the question accordingly. Also not that when you write \text{exp} rather than \exp then you don't get proper spacing in things like $5\exp3;$ you get instead $5\text{exp}3.$ And with \exp the spacing depends on context so that you see more space to the right of $\exp$ in $\exp3$ than in $\exp(3). \quad$ Aug 3, 2020 at 4:33

Working with the log-likelihood is easier. We write $$\ell(\theta_1, \theta_2 \mid n_1, n_2, \bar x_1, \bar x_2) = -(n_1 + n_2) \log (\theta_1 + \theta_2) - \frac{n_1 \bar x_1}{\theta_1} + \frac{n_2 \bar x_2}{\theta_2}.$$ Note that this function is subject to the restrictions $$\theta_1, \theta_2 > 0, \quad n_1, n_2 \in \mathbb Z^+, \quad \bar x_1 > 0, \quad \bar x_2 \le 0.$$ Taking the partial derivatives with respect to $$\theta_1$$, $$\theta_2$$ and equating these to $$0$$ yield respectively $$\frac{\partial \ell}{\partial \theta_1} = -\frac{n_1 + n_2}{\theta_1 + \theta_2} + \frac{n_1 \bar x_1}{\theta_1^2} = 0, \\ \frac{\partial \ell}{\partial \theta_2} = -\frac{n_1 + n_2}{\theta_1 + \theta_2} - \frac{n_2 \bar x_2}{\theta_2^2} = 0.$$ I leave it as an exercise for you to solve this simultaneous system (it is not difficult) and show that the unique critical point is $$(\theta_1, \theta_2) = \left(\frac{n_1 \bar x_1 + \sqrt{-n_1 \bar x_1 n_2 \bar x_2}}{n_1 + n_2}, \frac{-n_2 x_2 + \sqrt{-n_1 \bar x_1 n_2 \bar x_2}}{n_1 + n_2}\right),$$ which would suggest that it is better to use the sufficient statistics $$T_1 = \sum_{i=1}^n X_i \mathbb 1(X_i > 0), \quad T_2 = - \sum_{i=1}^n X_i \mathbb 1(X_i \le 0);$$ that is to say, $$T_1$$ is the sample total of positive observations, and $$T_2$$ is the negative of the sample total of negative or zero observations (thus is negative or zero). Then we may rewrite the joint MLE as $$(\hat \theta_1, \hat \theta_2) = \left(\frac{T_1 + \sqrt{T_1 T_2}}{n}, \frac{T_2 + \sqrt{T_1 T_2}}{n} \right),$$ which makes the symmetry apparent and does away with the auxiliary variables $$n_1, n_2$$.

• very nice explanation (+1) Aug 3, 2020 at 10:30

After your latest edit, the likelihood you calculated is

$$L(\underline{\theta})=\left(\frac{1}{\theta_1+\theta_2}\right)^n\exp\left\{-\frac{n_1\overline{X}_1}{\theta_1}+\frac{n_2\overline{X}_2}{\theta_2}\right\}$$

where $$\underline{\theta}=[\theta_1;\theta_2]$$ is a vector of parameters

To maximize it you have to derive with respect the two parameters (calculating the profile likelihood).

• I’ve tried that but can’t get a closed form soliton.
– nvm
Aug 3, 2020 at 5:38