|
||||||
Matlab is one of the most popular, powerful statistical software programs available. Running a basic t-test in Matlab helps determine significance between groups.
In research it's important to be able to quantify differences. How does a person prove that two groups are significantly different? How does one determine if a single population has a mean value significantly different from what is expected? What if you can clearly see the difference between populations for a measured statistic but the averages end up being the same? This case can easily happen, given some outliers that skew group data. A t-test can resolve this question. What is a t-test?A t-test is a statistical test where the experimenter puts forth a null hypothesis (or H-naught), which means the experimenter assumes there is no significant or real difference between two groups. Originally created by William Sealy Gosset in 1908 to help easily determine the quality of stout, he was forced to publish his statistical finding under the pen name "Student" by his employer (Guiness). Hence, the test came to be known as "Student's t-test." t-tests Rely on the Following AssumptionsTo reliably run a t-test, the two most fundamental assumptions one needs are the number of samples in the dataset(s) must be positive, and the population data must follow a normal distribution. Oftentimes the t-test will still work even if the distribution is close to normal. Determining Which t-test to UseA one-sample t-test is used when an experimenter has a single population and one wants to determine if the mean significantly differs from an assumed value. To use this test, the experimenter must have some idea of the expected value from which they want to measure the difference of the mean of the dataset. An independent two-sample t-test should be used if the experimenter wants to determine whether or not the averages from two sample sets differ from one another significantly. To use this test the sample sizes must be equal, as must variance. There are two t-tests available for unequal sample sizes, one with assumed equal variance in the sample groups and one with assumed unequal variance. Running a One-sample t-test in MatlabTo run a t-test in Matlab one must first define variables. If one already has a list of number they want to compare (from Excel, for example) it's possible to do a cut and paste function. To run a one-sample t-test or a paired t-test use the ttest function. To run an unpaired ttest (between groups from different populations or of different sizes) use the ttest2 function. Open Matlab and define variables by choosing a letter or word and listing the first dataset between brackets. For example, to define the first group as "a," type: a=[2,4,6]. After inserting a list of numbers, close the bracket and press enter. Matlab should then show the list of numbers it has saved as the variable set. Do this for the second group (if necessary). Remember, the fundamental setup of the t-test is one assumes the null hypothesis (defined by "H" in Matlab) is true. The null hypothesis means there is no significant difference. If one now types H=ttest(a,[your assumed value]) and press return, Matlab will return a value of either 0 or 1. 0 means the null hypothesis is incorrect and there is a significant difference between the two groups. 1 means the null hypothesis is correct: no significant difference. Running a Two-sample t-testThe most common t-test is testing for a difference between two population groups, whether they are of equal size or unequal size. To test the difference between two groups (with no assumed mean value, type H=ttest2(a,b) and press return. Retrieving the Significance ValueIn many cases one will want to know not only whether the groups are significantly different, but what the significance value is. A Pearson's correlation coefficient (p value) can show this significance. A correlation of 1 is no difference at all. The smaller the correlation value, the more significant the difference between the two groups. In general, a p value equal to or less than 0.05 is considered significant and less than 0.01 is considered very significant. To see the p value type [H,P]=ttest2(a,b) and Matlab will return the null hypothesis value followed by the p value. Matlab is a powerful statistical mathematics tool and also serves as a base for writing programs. It is especially helpful in graphical statistical analysis and is highly recommended for mathematicians and researchers in virtually any line of study.
The copyright of the article How to Perform a t-Test in Matlab in Scientific Research Methods is owned by Sarah Mikula. Permission to republish How to Perform a t-Test in Matlab in print or online must be granted by the author in writing.
|
||||||
|
|
||||||
|
|
||||||