# Regression analysis of two data sets

I have two data sets, both resemble $y = x^2$, but say I don't know that yet. They are both evenly sampled, but the sampling rates are not the same between them, and they exist over different domains. Both sets may return data at the same $x$ value. How do I perform a regression over such a data set?

If I combine them into one large dataset, the fit will be weighted towards the dataset that has the higher density points (or the one with more total points maybe?) But, I want the two datasets to be weighted evenly in the $x$ dimension - that is, even though there is much higher data density around the point $x=5$ for the red set compared to the black set, I would want the black point to have as much weight as the red points between say $x = 4.5$ and $x=5.5$. I feel this is a very naive way of saying it, but perhaps someone with a stats background can fix this up.

• Why do you want to merge these dataset ? You have a superbe fit for each one. To this respect the pink curve is deceiving. Why not instead adding a dummy variable in your regression indicating if your point comes from the dataset 1 or 2 ? – brumar Jun 24 '15 at 7:11
• Because I want to reduce them to one set that best matches the setup. – James Jun 24 '15 at 11:10
• What do you call the "setup" ? y is your dependent variable, right ? Oh...Or maybe it's just a fictitious example to have an answer for your more complex case ? – brumar Jun 24 '15 at 12:26
• Yes, this is a simplified version of something else I want to do. – James Jun 25 '15 at 0:09

You could use weighted regression to achieve your goal. Apart from the data, for each observation a weight is given that indicates how important the error for that observation is. More information and an example here: How to use weights in function lm in R?

• How can the weights be calculated? – James Jun 25 '15 at 0:10
• The weights are subjective. In your case, the Data1 errors shoud be weighed more than the Data2 errors. Try 2 and 1 respectively first, and go from there. – spdrnl Jun 25 '15 at 9:48

Are these two datasets obtained by sampling the same population? And is the data longitudinal/correlated (eg. are you sampling the same two lab mice over and over again)? If the two datasets are sampled from the same population, and the data is not longitudinal/correlated, then in my mind it is fine to merge the data. You are simply adding more data points to your sample. The difference in domain is not an issue, as long as you actually want to model the data for that entire domain.

But, I want the two datasets to be weighted evenly in the x dimension - that is, even though there is much higher data density around the point $x=5$ for the red set compared to the black set, I would want the black point to have as much weight as the red points between say $x=4.5$ and $x=5.5$.

By this, do you mean that you want ONE black point at $x=5$ to equal in weight the MULTIPLE red points between $x=4.5$ and $x=5.5$? This seems strange to me, because you're essentially saying that you trust the black measurements much more than the red measurements, but if you are using the same setup and same sampling population, I don't see why this should be the case?

• From what it sounds like, you are not trying to compare the two methods, but rather trying to define the relationship between $x$ and $y$ using the two datasets. If the only difference between the two datasets are sampling intervals (I assume this is what you meant by resolution?), and the data is not sensitive to any other parameters like time (ie. on average, you would not expect to observe different $y$ given the same $x$, within measurement and random error), I see no problem in combining the data and fitting one model to it. – dwhdai Jan 4 '17 at 15:29