Outlier detection algorithm: Datasets lumped together or separated? Say, I have two groups of human subjects; groupA and groupB, with a size of nA and nB, respectively.
Then, I do the same measurement on both groups (it is actually some results from a CFD simulation); datasetA and datasetB.
I know it is recommended to do one's best to not remove any data, but I want to detect my outliers from the datasets. The end goal is to see if the two datasets are statistically different.
Now my question is if I have to mix both datasets datasetA and datasetB together and then carry out the desired outlier algorithm on the lumped dataset or I have to run one algorithm for each of the datasets separately?
Please, support your answer with a reference, if possible please.
 A: If the two datasets are indeed statistically different, then mixing would be a bad idea. Consider two extreme scenarios:

*

*Say observations in $A$ come from $N(0,1)$ and observations in $B$ come from $N(5,1)$. Now an observation of $5$ in $A$ is clearly an outlier prior to mixing and not after. So by removing outliers from the mixed set, you will miss some outliers.


*Say $n_B>n_A$ by a considerable margin. So the distribution of the combined set is more inclined towards $N(5,1)$. If the difference in number of observations is considerably different then an observation of, say, $-1.5$ may be detected as an outlier in the combined set while it ought not to be.
On the other hand if the two sample sets do come from the same distribution then of course combining the data increases observations and therefore the accuracy of estimates of the underlying distribution.
Overall, you should try both while keeping the above points in mind and depending on what results you get from testing the two distribution for statistical difference, take a call.
