1
$\begingroup$

I tried Expectation-Maximization (EM) based fitting using the mixfit function from the mixR package in the R environment. It yielded a normal mixture model with 2 components: 1) pi 0.21, mu: 0.47, sd: 0.31 2) pi 0.78, mu 2.55, sd: 1.16

However the fit would probably be better if the first component was fitted with half-normal (or truncated normal) as mixture density type instead of normal (with mu close to 0, no values below 0). The function mixfit can only deal with normal, gamma or beta distributions.

My question: is there a function suitable for EM based fitting of a mixture of a half normal (truncated normal) and a normal distribution?

$\endgroup$
1
  • $\begingroup$ Thanks for your answer, it is indeed about finding an R function which is already written, sicne I don't have the experience to combine the functions which already exist for the truncated normal distribution and fitting a mixture of distributions myself:( $\endgroup$
    – Clarize
    Commented Apr 14, 2020 at 9:17

1 Answer 1

3
$\begingroup$

E-step: write complete log-likelihood $$\sum_{i=1}^n \mathbb{I}_1(z_i) \log \pi_1 f(x_i;\mu_1,\sigma_1) + \mathbb{I}_2(z_i) \log \pi_2 f(x_i;\mu_2,\sigma_2)$$and take expectation $$\mathbb{E}_{\theta^0}\left[\sum_{i=1}^n \mathbb{I}_1(z_i) \log \pi_1 f(x_i;\mu_1,\sigma_1) + \mathbb{I}_2(z_i) \log \pi_2 f(x_i;\mu_2,\sigma_2)|x_1,\ldots,x_n\right]$$ as$$\sum_{i=1}^n \mathbb{P}(Z_i=1|x_i,\theta^0) \log \pi_1 f(x_i;\mu_1,\sigma_1) + \mathbb{P}(Z_i=2|x_i,\theta^0) \log \pi_2 f(x_i;\mu_2,\sigma_2)$$where $$\mathbb{P}(Z_i=1|x_i,\theta^0)=\pi_1^0 f(x_i;\mu_1^0,\sigma_1^0)\Big/\pi_1^0 f(x_i;\mu_1^0,\sigma_1^0)+\pi_2^0 f(x_i;\mu_2^0,\sigma_2^0)$$

M-step: maximise above in $\theta=(\pi_1,\mu_1,\sigma_1,\mu_2,\sigma_2)$, for instance $$\hat\pi_1=\frac{1}{n} \sum_{i=1}^n \mathbb{P}(Z_i=1|x_i,\theta^0)$$ Since$$f(x;\mu,\sigma)=\exp\{-(x-\mu)^2/2\sigma^2\}\big/\sqrt{2\pi}\sigma\Phi(-\mu/\sigma)$$the maximisation in $(\mu,\sigma)$ requires numerical optmisation tools.

$\endgroup$
1
  • $\begingroup$ Thank you so much Xi'an for your quick response! Can you show me how this looks like in R? $\endgroup$
    – Clarize
    Commented Apr 14, 2020 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.