Geometric Waiting Time MLE If the time is measured in discrete periods, a model that is often used for the time $X$ failure of an item is:$$P_{\theta}[X=k]=\theta^{k-1}(1-\theta), k=1,2,...$$
where $0<\theta<1$. Suppose that we only record the time of failure, if failure occurs on or before time $r$ and otherwise just note that the item has lived at least $r+1$ periods. Hence, we observe $Y_1,...,Y_n$, which are iid and have common frequency function:
$$f(k,\theta)=\theta^{k-1}(1-\theta), k=1,...,r$$
$$f(r+1,\theta)=1-P_\theta[X\leq r]=1-\Sigma_{k=1}^r(1-\theta)=\theta^r$$
The $r+1$ notation, means survival for at least $r+1$ periods. Let $M=$number of indices i such that $Y_i=r+1$. I want to derive that the MLE of $\theta$ based on $Y_1,...,Y_n$ is:
$$\hat{\theta}(\mathbf{Y})=\frac{\Sigma_{i=1}^nY_i-n}{\Sigma_{i=1}^nY_i-M}$$
but I'm pretty confused about it.
Note: This process is known as Censored Geometric Waiting Time.
Any help would be appreciated!
 A: Brace yourself, Math ahead !
The likelihood is defined to be the probability to observed your data under a given parameters : $P(Y_1,...,Y_n|\theta)$
Let's consider that all event are iid:
$P(Y_1,...,Y_n|\theta) = \prod_1^n{P(Y_i|\theta})$
Now let's split the case where $Y_i = r+1$ from the rest:
$P(Y_1,...,Y_n|\theta) = \prod_{Y_i<r+1}{P(Y_i|\theta}) * \prod_{Y_i=r+1}{P(Y_i|\theta})$
Now we know the expression of the probability for both of these product:
$P(Y_1,...,Y_n|\theta) = \prod_{Y_i<r+1}{P(X=Y_i|\theta)} * \prod_{Y_i=r+1}{P(X>=Y_i|\theta)}$
$P(Y_1,...,Y_n|\theta) = \prod_{Y_i<r+1}{(\theta^{Y_i-1}*(1-\theta))} * \prod_{Y_i=r+1}{\theta^{Y_i-1}}$
$P(Y_1,...,Y_n|\theta) = \prod_{Y_i<r+1}{(\theta^{Y_i-1}*(1-\theta))} * \prod_{Y_i=r+1}{\theta^{r}}$
$P(Y_1,...,Y_n|\theta) = \prod_{Y_i<r+1}{(\theta^{Y_i-1}})*(1-\theta)^{n-M} * \theta^{M*r}$
From Now on it is easier to take the log : $L(\theta) = log(P(Y_1,...,Y_n|\theta))$
$L(\theta) = \sum_{Y_i<r+1}[(Y_i-1)*log(\theta)]+(n-M)*log(1-\theta) + M*r*log(\theta)$
$L(\theta) = log(\theta) * [\sum_{Y_i<r+1}Y_i - \sum_{Y_i<r+1}[1]] +(n-M)*log(1-\theta)+ M*r*log(\theta)$
$L(\theta) = log(\theta) * [\sum_{Y_i<r+1}Y_i - (n-M)] +(n-M)*log(1-\theta)+ M*r*log(\theta)$
Now we take the derivative with respect to $\theta$:
$L'(\theta) = \frac{\sum_{Y_i<r+1}Y_i - (n-M)}{\theta} -\frac{n-M}{1-\theta} + \frac{M*r}{\theta}$
We then look for $\theta$ such that $L'(\theta)=0$
$\frac{\sum_{Y_i<r+1}Y_i - (n-M)}{\theta} -\frac{n-M}{1-\theta} + \frac{M*r}{\theta} = 0$
$\frac{\sum_{Y_i<r+1}Y_i - (n-M)}{\theta} + \frac{M*r}{\theta} = \frac{n-M}{1-\theta}$
$\frac{1-\theta}{\theta} = \frac{n-M}{M*r+\sum_{Y_i<r+1}Y_i - (n-M)}$
$\frac{1-\theta}{\theta} = \frac{n-M}{M*(r+1)+\sum_{Y_i<r+1}Y_i - n}$
$\frac{1-\theta}{\theta} = \frac{n-M}{\sum_{Y_i=r+1}Y_i+\sum_{Y_i<r+1}Y_i - n}$
$\frac{1-\theta}{\theta} = \frac{n-M}{\sum_{1}^nY_i - n}$
$\frac{1-\theta}{\theta} = \frac{n-M}{\sum_{1}^nY_i - n}$
$\frac{1}{\theta} = \frac{n-M}{\sum_{1}^nY_i - n} + 1$
$\frac{1}{\theta} = \frac{n-M+\sum_{1}^nY_i - n}{\sum_{1}^nY_i - n}$
$\frac{1}{\theta} = \frac{\sum_{1}^nY_i - M}{\sum_{1}^nY_i - n}$
$\theta = \frac{\sum_{1}^nY_i - n}{\sum_{1}^nY_i - M}$
Done !
