this is the main function for which we need to add tests. Do you have tests for unbalanced data? Unequal nobs is the case that I don't fully understand yet.

I don't see yet how it works, and still need to check some references