title: Fitting a binormal distribution in R
body: <p>As from title, I have some data that is roughly binormally distributed and I would like to find its two underlying components.</p>
  
  <p>I am fitting to the data distribution the sum of two normal with means m<sub>1</sub> and m<sub>2</sub> and standard deviations s<sub>1</sub> and s<sub>2</sub>. The two gaussians are scaled by a weight factor such that w<sub>1</sub>+w<sub>2</sub> = 1</p>
  
  <p>I can succeed to do this using the <code>vglm</code> function of the <code>VGAM</code> package such as:</p>
  
  <pre><code>    fitRes &lt;- vglm(mydata ~ 1, mix2normal1(equalsd=FALSE), 
            iphi=w, imu=m1, imu2=m2, isd1=s1, isd2=s2))
  </code></pre>
  
  <p>This is painfully slow and it can take several minutes depending on the data, but I can live with that.</p>
  
  <p>Now I would like to see how the distribution of my data changes over time, so essentially I break up my data in a few (30-50) blocks and repeat the fit process for each of those.</p>
  
  <p>So, here are the questions:</p>
  
  <p>1) how do I speed up the fit process? I tried to use <code>nls</code> or <code>mle</code> that look much faster but mostly failed to get good fit (but succeeded in getting all the possible errors these function could throw on me). Also is not clear to me how to impose limits with those functions (w in [0;1] and w<sub>1</sub>+w<sub>2</sub>=1)</p>
  
  <p>2) how do I automagically choose some good starting parameters (I know this is a $1 million question but you'll never know, maybe someone has the answer)? Right now I have a little interface that allow me to choose the parameters and visually see what the initial distribution would look like which is very cool, but I would like to do it automatically for this task.</p>
  
  <p>I thought of relying on the x corresponding to the 3rd and 4th quartiles of the y as starting parameters for the two mean? Do you thing that would be a reasonable thing to do? </p>