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

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).

-Tinku

• Is there a reason that you cannot subtract, the given non-zero value you want to test against, from the appropriate sample and then test if their means are equal? You do assume that the distributions are invariant under translation right? – usεr11852 Nov 20 '15 at 18:12
• Thank you for your suggestion to subtract the given non-zero value. I followed your suggestion today, but I am getting results that prima facie look wrong. I understand that if the results are indeed wrong then the error is not in subtracting the non-zero given value but in something else that I am doing wrong. I will investigate more and if I am unable to figure out where I am going wrong, I will let you know (so that, in case you have some spare time, you can look at it and kindly let me know where I am going wrong). Thanks again. – TInku Nov 22 '15 at 3:22
• Hi, I tried to investigate all that I could but I am still getting unexpected results. As there is limit on number of characters here in the Comments section, I put down the details of what I am doing in a google doc Difference between sample means If you happen to get some free time, I will be grateful if you can shed light on where I am going wrong. Many Thanks @usεr11852 – TInku Dec 2 '15 at 19:48
• i am very busy, I will probably look this up during the weekend. – usεr11852 Dec 2 '15 at 20:21
• Hi, it will help me immensely if you can have a look at the issue I am facing when you get some free time. Many thanks for your help. @usεr11852 – TInku Dec 11 '15 at 17:05

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).
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.