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$
$\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?

  • 1
    $\begingroup$ 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). $\endgroup$ Mar 16, 2014 at 15:21
  • $\begingroup$ @gung I am interested in the general issue of comparing two fits. I am also OK with migrating to Stack Overflow. $\endgroup$
    – abcihep
    Mar 17, 2014 at 12:14
  • $\begingroup$ @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". $\endgroup$
    – abcihep
    Mar 17, 2014 at 14:16
  • $\begingroup$ 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. $\endgroup$
    – Erik
    Mar 17, 2014 at 15:59

1 Answer 1


What you are looking for is a measure to see how different two models are. Whether they are different comes down to asking whether this distance is zero.

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.