Solved – How to test that the difference between two sample means is greater that a given value (in Matlab)

MATLABt-test

I (unfortunately) only have an elementary knowledge of statistics, and so please excuse me for my following basic question.

I have two independent samples (with sample size of 60 and 765 respectively) and I need to test if the mean of first sample is greater than the mean of second sample by a non-zero given value (the two samples have unequal variance). Since, Matlab is the tool that is used in my workplace, I need to do this in Matlab (I had looked at the "ttest2" function in Matlab, but from the help document,I could not figure out how to use ttest2 to test whether the difference between two sample means is greater than a given non-zero value).

Many thanks in advance.

-Tinku

Best Answer

I am not a Matlab expert, but looking at the documentation for ttest2 it looks like there is not an option to change the null value (what the difference is under the null hypothesis).

But it can return a confidence interval on the difference between the 2 means and you can use a confidence interval to do a hypothesis test (the yes/no part, not the exact p-value). Create the confidence interval and look to see if the difference that you are interested in is within the interval. If it is in the interval then that means the result is not statistically significant, if it is outside of the interval then it is statistically significant.

Another option is that if you subtract the null value difference from each value in one set (the one you expect to be higher) then that adjusts the mean appropriately and does not change the variances or other values. So you can pass the new vectors (one with the subtraction done) to the ttest2 function and it will give you the appropriate p-value.