 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: RE: Evaluate cdf and pdf of mixture of normals

 From "Feiveson, Alan H. (JSC-SK311)" To "statalist@hsphsun2.harvard.edu" Subject st: RE: Evaluate cdf and pdf of mixture of normals Date Fri, 2 Sep 2011 08:03:25 -0500

```Fernando - For any mixture, the CDF (and also the PDF) is just the weighted sum of its components. So if you are asking how to do this in Stata, it depends on how those component  CDFs, etc are stored in your application. Are they Stata "variables" evaluated at each observation of the data set? Or what?

Al Feiveson

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Fernando Luco
Sent: Thursday, September 01, 2011 2:58 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: Evaluate cdf and pdf of mixture of normals

Dear statalisters,

I'm trying to compute the cdf and pdf of a mixture of normals but the
specifics of my problem are doing this quite difficult, so any ideas
would be really appreciated.

My data, and what I want to do is as follows. I have i people that may or
may not be present at t situations. Each person has two variables
associated, y(it)
and x(it). I assume that the distribution of y(it)
satisfies y(it)=x(it)+e(it) where the distribution of e(it) is a mixture of
normals. Let's assume that is only a mixture of two normals to make it easy
and that they have means mu1 and mu2 and std. dev sigma1 and sigma2, and
are independent.
I have the means, variances and mixing probabilities of the distribution of
e(it). So, my data is t, i, y(it) and x(it).

I have heterogeneity between people so the distributions of y(i) differ
among
people, in particular, the mean changes.
So, for example, when considering the cdf of person 1 the mean should be x11
plus the two means of the normal distributions (I guess
that they enter weighted by the mixing probabilities), for situation 1, but
for situation 2 then the mean should be x12 plus the weighted means. For
person 2
the mean would be x21 plus the weighted means of the
normals for situation one, and x22 for situation two, etc. The variance is
common. I want to evaluate the cdf and the pdf at y(it).

Finally, not every people are present in every t. So, when person i is not
present then the cdf and pdf  should be empty.

Does anybody know how I can compute this in Stata?

Fernando
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```