title: Least squares fitting of multivariate data with both shared and independent parameters
body: <p>I have N datasets with m points that are cuts of a function f(x1,x2) at constant x1 values. I have a formula to fit these functions that has parameters that vary for each dataset (i.e. depend on x1) and other parameters that are the same for all datasets (i.e. independent of x1 and x2).</p>
  
  <p><strong>The question: if I were to do a least squares fit to my data to determine all these parameters, what is the most efficient method to do so?</strong> </p>
  
  <p>Naively, I would do a nested least squares regression. I would define an error function that takes in the shared parameters. Keeping those parameters fixed, the function would do least squares fits on all of the datasets to determine the independent parameters. Then this error function would return the total square error and the best independent fit parameters. Sending this function itself through a least squares fit would then find the best shared parameters.</p>
  
  <p>Is there a more efficient method of doing this?</p>