2
$\begingroup$

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

$\endgroup$
5
  • 1
    $\begingroup$ 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? $\endgroup$
    – usεr11852
    Nov 20, 2015 at 18:12
  • $\begingroup$ 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. $\endgroup$
    – TInku
    Nov 22, 2015 at 3:22
  • $\begingroup$ 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 $\endgroup$
    – TInku
    Dec 2, 2015 at 19:48
  • $\begingroup$ i am very busy, I will probably look this up during the weekend. $\endgroup$
    – usεr11852
    Dec 2, 2015 at 20:21
  • $\begingroup$ 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 $\endgroup$
    – TInku
    Dec 11, 2015 at 17:05

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ Many thanks for your detailed explanation. I followed the second option suggested by you but I am getting unexpected results. I understand that the unexpected results are due to something wrong that I am doing, and so I will be investigating more. However, in case I am unable to figure out where I am going wrong I will let you know (so that in case you get some free time out of your schedule, you can point to me what wrong I am doing). Thank you again for your help. Best $\endgroup$
    – TInku
    Nov 22, 2015 at 3:29
  • $\begingroup$ Hi, I am sorry for the delay in getting back on this. 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. @GregSnow $\endgroup$
    – TInku
    Dec 2, 2015 at 19:57
  • $\begingroup$ Hi, if you get a chance can you please have a look at where I am going wrong in conducting the t-test. I am very grateful for your guidance. Thank you. @Greg $\endgroup$
    – TInku
    Dec 15, 2015 at 20:00
  • $\begingroup$ @TInku, I don't know matlab very well, so I am not the best person to find problems with your code, it looks ok to me. Have you tried adding a number greater than 6? it could be that you have low power to detect the size you are looking at. $\endgroup$
    – Greg Snow
    Dec 15, 2015 at 22:22

Your Answer

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

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