# Testing that two models from two different data sets are independent

I have two different sets $(n_1=47$, $n_2=23)$ obtained under different conditions. I fit two different functions $(\text{Fu}_1$, $\text{Fu}_2)$ in MATLAB. $\text{Fu}_1$ was fit using the first data set, and $\text{Fu}_2$ was fit using the second data set.

$\text{Fu}_1(x,y) = A_1 + B_1x + B_2y$
and
$\text{Fu}_2(x,y) = A_2 + B_3x + B_4y$

When I plot these functions, $\text{Fu}_1$ with the first data set $(n_1=47)$ and $\text{Fu}_2$ with second data set $(n_2=23)$, they are separated in space.

How do I test in MATLAB that the models are indeed different?

• This question seems to be only about how to do this in MATLAB. Thus, it would be off-topic for CV (see our help center), but would be on-topic on Stack Overflow. If you have a question about the substantive statistical issues involved here, please edit to clarify; if not, we can migrate this for you (please don't cross-post, though). Mar 16, 2014 at 15:21
• @gung I am interested in the general issue of comparing two fits. I am also OK with migrating to Stack Overflow. Mar 17, 2014 at 12:14
• @Glen_b you are correct my wording of the title is wrong. It should have read "Testing that two models from two independent data sets are different". Mar 17, 2014 at 14:16
• I think the old title (different vs. independent) was much clearer. I voted against the change but it came out two for vs one against.
– Erik
Mar 17, 2014 at 15:59

However, generally we fit ever so slightly different models to different observed data sets which arose from the same process, so we would like to define some limit $d$ and say that a distance below $d$ means that the models are similar enough.
For example, this $d$ might be based on the likelihood that the two data sets arose from one and the same model.
A simple measure can also be defined just by the distance in parameters: $(A_1-A_2)^2 + (B_1-B_3)^2+(B_2-B_4)^2$. Note however, that with such a measure, the limit $d$ becomes quite arbitrary and cannot be assigned any statistical importance.