# Computing the likelihood function

Let $$x=(x_1,\dots,x_n)$$ be a sample from $$X_1,\dots,X_n$$ independent identically distributed random variables with pdf $$f(x)=(1-\theta)1_{[-\frac{1}{2},0]}(x)+(1+\theta)1_{(0,\frac{1}{2}]}(x)$$ where $$\theta\in(-1,1)$$. Compute the likelihood function and find the maximum likelihood estimator for the parameter $$\theta$$.

Provided that my $$X_i$$'s are continous random variables I do the following: $$L(x;\theta)=\mathbb{P}(X_1\leq x_1,\dots,X_n\leq x_n)\overset{i.i.d.}{=}\prod_{i=1}^{n}\mathbb{P}(X\leq x_i)$$ Now, depending on the value of $$x_i$$, $$\mathbb{P}(X\leq x_i)$$ can have the following values. If $$x_i\in[-1/2,0]$$ then $$\mathbb{P}(X\leq x_i)=\int_{-1/2}^{x_i}(1-\theta)dx=(1-\theta)(x_i+\frac{1}{2})$$ or $$\mathbb{P}(X\leq x_i)=(1+\theta)x_i$$ if $$x_i\in(0,1/2]$$. Now, since the sample has size $$n$$ we can suppose that $$n=n_1+n_2$$ where $$n_1$$ is the number of times that the $$x_i$$ has fallen in $$[-1/2,0]$$ and $$n_2$$ the number of times that $$x_i$$ has fallen in $$(0,1/2]$$. This gives us $$L(x;\theta)=(1-\theta)^{n_1}\left(x_i+\frac{1}{2}\right)^{n_1}(1+\theta)^{n_2}x_i^{n_2}$$ RIGHT? Another way is to just say $$L(x;\theta)=\prod_{i=1}^{n}f(x_i)$$. Now supposing that $$n=n_1+n_2$$ we have $$L(x;\theta)=(1-\theta)^{n_1}(1+\theta)^{n_2}$$ which makes more sense and is more straight forward, yet it does not depend on the sample which is odd. Can this happen?

I'm just happy if anyone could help me find the likelyhood function, MLE is secondary. Any help will be really much appreciated.

• $n_1=\sum_{i=1}^n 1_{[-\frac12,0]}(x_i)$ very much depends on the sample. Commented Jun 15 at 15:38

$$L(x;\theta)=\prod_{i=1}^{n}f(x_i)$$ is the correct formula for the likelihood when the underlying distribution has a density. The $$n_1$$ and $$n_2$$ are defined as $$n_1=\operatorname{Card}\left(\left\{i\in\{1,\dots,n\},-1/2\leqslant x_i\leqslant 0\right\}\right)$$ and $$n_2=\operatorname{Card}\left(\left\{i\in\{1,\dots,n\},0< x_i\leqslant 1/2\right\}\right)$$, which do depend on the sample.
In general, likelihood is only defined up to proportionality. Here the likelihood for $$\theta$$ is proportional to both your expressions.
Since $$\left(x_i+\frac{1}{2}\right)^{n_1}$$ and $$x_j^{n_2}$$ do not depend on $$\theta$$, this means that, given the observations, $$(1-\theta)^{n_1}\left(x_i+\frac{1}{2}\right)^{n_1}(1+\theta)^{n_2}x_j^{n_2}$$ and $$(1-\theta)^{n_1}(1+\theta)^{n_2}$$ are proportional to each other as functions of $$\theta$$ and so essentially the same likelihood function. That being said, I am not sure that $$\prod\limits_{i=1}^{n}\mathbb{P}(X\leq x_i)$$ does give a likelihood function in general - but here the uniform parts of the density may have saved you.
You also could have introduced a $${n_1+n_2 \choose n_1}$$ multiplicative term if you had failed to record the order of your exchangeable observations but, since it too does not depend on $$\theta$$, it would make no essential difference.
Whichever of these likelihood functions you use, the maximum likelihood estimator for $$\theta$$ will then be the intuitively attractive $$\dfrac{n_2-n_1}{n_1+n_2}$$. All that matters here is how many positive and negative observations you see.
• Okay, so $\widehat{\theta}=\frac{n_{2}-n_{1}}{n_{1}+n_{2}}$. If I am asked to compute the Cramer Rao bound to see if my estimator is eficient or not I should compute the variance of my estimator and see that this equals $I(\theta)^{-1}$, where this last term is the inverse of the Fisher information right? The problem comes when I try to compute the variance of the estimator since $\mathbb{V}(\widehat{\theta})=\mathbb{V}(\frac{n_2-n_1}{n})\overset{?}{=}\frac{n_2-n_1}{n}$. For the Fisher's information, a simple exercise shows $I(\theta)=\frac{n_1}{(1-\theta)^2}+\frac{n_2}{(1+\theta)^2}$ Commented Jun 15 at 15:03
• Essentially this question becomes equivalent to sampling from a binominal distribution with parameters $n$ and $p=\frac{1+\theta}{2}$. Things like the Fisher information and MVUE are well known for binomial distributions. Commented Jun 16 at 2:02