{"id":11662,"date":"2019-12-25T18:32:03","date_gmt":"2019-12-25T16:32:03","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?post_type=dt_lessons&#038;p=11662"},"modified":"2019-12-25T18:32:03","modified_gmt":"2019-12-25T16:32:03","slug":"t-test-formula","status":"publish","type":"dt_lessons","link":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/","title":{"rendered":"T-Test Formula"},"content":{"rendered":"<div id=\"rdoc\">\n<p>This article describes the <strong>t-test formula<\/strong> for one-sample, two-independent samples and paired samples t-test. The t-test formula is also referred as:<\/p>\n<ul>\n<li><em>t-test equation<\/em>,<\/li>\n<li><em>t-score equation<\/em>,<\/li>\n<li><em>t-test statistic formula<\/em><\/li>\n<li><em>formula for t-test<\/em><\/li>\n<\/ul>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#one-sample-t-test\">One sample t-test formula<\/a><\/li>\n<li><a href=\"#independent-t-test\">Independent t-test formula<\/a>\n<ul>\n<li><a href=\"#student-t-test\">Student t-test formula<\/a><\/li>\n<li><a href=\"#welch-t-test\">Welch\u2019s t test formula<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#paired-t-test\">Paired t-test formula<\/a><\/li>\n<li><a href=\"#related-article\">Related article<\/a><\/li>\n<\/ul>\n<\/div>\n<div class='dt-sc-hr-invisible-medium  '><\/div>\n<div class='dt-sc-ico-content type1'><div class='custom-icon' ><a href='https:\/\/www.datanovia.com\/en\/product\/practical-statistics-in-r-for-comparing-groups-numerical-variables\/' target='_blank'><span class='fa fa-book'><\/span><\/a><\/div><h4><a href='https:\/\/www.datanovia.com\/en\/product\/practical-statistics-in-r-for-comparing-groups-numerical-variables\/' target='_blank'> Related Book <\/a><\/h4>Practical Statistics in R II - Comparing Groups: Numerical Variables<\/div>\n<div class='dt-sc-hr-invisible-medium  '><\/div>\n<div id=\"one-sample-t-test\" class=\"section level2\">\n<h2>One sample t-test formula<\/h2>\n<p>The one sample t-test formula is used to compare the mean of one sample to a known standard mean. The the one-sample t-test formula can be written as follow:<\/p>\n<p><span class=\"math display\">\\[<br \/>\nt = \\frac{m-\\mu}{s\/\\sqrt{n}}<br \/>\n\\]<\/span><\/p>\n<p>where,<\/p>\n<ul>\n<li><span class=\"math inline\">\\(m\\)<\/span> is the sample mean<\/li>\n<li><span class=\"math inline\">\\(n\\)<\/span> is the sample size<\/li>\n<li><span class=\"math inline\">\\(s\\)<\/span> is the sample standard deviation with <span class=\"math inline\">\\(n-1\\)<\/span> degrees of freedom<\/li>\n<li><span class=\"math inline\">\\(\\mu\\)<\/span> is the theoretical mean<\/li>\n<\/ul>\n<p>The p-value, corresponding to the absolute value of the t-test statistics (|t|), is computed for the degrees of freedom (df): <code>df = n - 1<\/code>.<\/p>\n<p><strong>How to interpret the one-sample t-test results?<\/strong><\/p>\n<div class=\"success\">\n<p>If the p-value is inferior or equal to the significance level 0.05, we can reject the null hypothesis and accept the alternative hypothesis. In other words, we conclude that the sample mean is significantly different from the theoretical mean.<\/p>\n<\/div>\n<\/div>\n<div id=\"independent-t-test\" class=\"section level2\">\n<h2>Independent t-test formula<\/h2>\n<p>The <strong>independent t-test formula<\/strong> is used to compare the means of two independent groups.The independent samples t-test comes in two different forms:<\/p>\n<ul>\n<li>the standard <em>Student\u2019s t-test<\/em>, which assumes that the variance of the two groups are equal.<\/li>\n<li>the <em>Welch\u2019s t-test<\/em>, which is less restrictive compared to the original Student\u2019s test. This is the test where you do not assume that the variance is the same in the two groups, which results in the fractional degrees of freedom.<\/li>\n<\/ul>\n<p>In this article, you will learn the <em>Student t-test formula<\/em> and the <em>Weltch t-test formula<\/em>.<\/p>\n<div id=\"student-t-test\" class=\"section level3\">\n<h3>Student t-test formula<\/h3>\n<p>If the variance of the two groups are equivalent (<strong>homoscedasticity<\/strong>), the t-test value, comparing the two samples (<span class=\"math inline\">\\(A\\)<\/span> and <span class=\"math inline\">\\(B\\)<\/span>), can be calculated as follow.<\/p>\n<p><span class=\"math display\">\\[<br \/>\nt = \\frac{m_A - m_B}{\\sqrt{ \\frac{S^2}{n_A} + \\frac{S^2}{n_B} }}<br \/>\n\\]<\/span><\/p>\n<p>where,<\/p>\n<ul>\n<li><span class=\"math inline\">\\(m_A\\)<\/span> and <span class=\"math inline\">\\(m_B\\)<\/span> represent the mean value of the group A and B, respectively.<\/li>\n<li><span class=\"math inline\">\\(n_A\\)<\/span> and <span class=\"math inline\">\\(n_B\\)<\/span> represent the sizes of the group A and B, respectively.<\/li>\n<li><span class=\"math inline\">\\(S^2\\)<\/span> is an estimator of the pooled variance of the two groups. It can be calculated as follow :<\/li>\n<\/ul>\n<p><span class=\"math display\">\\[<br \/>\nS^2 = \\frac{\\sum{(x-m_A)^2}+\\sum{(x-m_B)^2}}{n_A+n_B-2}<br \/>\n\\]<\/span><\/p>\n<p>with degrees of freedom (df): <span class=\"math inline\">\\(df = n_A + n_B - 2\\)<\/span>.<\/p>\n<\/div>\n<div id=\"welch-t-test\" class=\"section level3\">\n<h3>Welch\u2019s t test formula<\/h3>\n<p>If the variances of the two groups being compared are different (<strong>heteroscedasticity<\/strong>), it\u2019s possible to use the Welch t-test, which is an adaptation of the Student t-test. The Welch t-statistic is calculated as follow :<\/p>\n<p><span class=\"math display\">\\[<br \/>\nt = \\frac{m_A - m_B}{\\sqrt{ \\frac{S_A^2}{n_A} + \\frac{S_B^2}{n_B} }}<br \/>\n\\]<\/span><\/p>\n<p>where, <span class=\"math inline\">\\(S_A\\)<\/span> and <span class=\"math inline\">\\(S_B\\)<\/span> are the standard deviation of the the two groups A and B, respectively.<\/p>\n<p>Unlike the classic Student\u2019s t-test, the Welch t-test formula involves the variance of each of the two groups (<span class=\"math inline\">\\(S_A^2\\)<\/span> and <span class=\"math inline\">\\(S_B^2\\)<\/span>) being compared. In other words, it does not use the pooled variance <span class=\"math inline\">\\(S\\)<\/span>.<\/p>\n<p>The <strong>degrees of freedom<\/strong> of <strong>Welch t-test<\/strong> is estimated as follow :<\/p>\n<p><span class=\"math display\">\\[<br \/>\ndf = (\\frac{S_A^2}{n_A}+ \\frac{S_B^2}{n_B})^2 \/ (\\frac{S_A^4}{n_A^2(n_A-1)} + \\frac{S_B^4}{n_B^2(n_B-1)} )<br \/>\n\\]<\/span><\/p>\n<div class=\"success\">\n<p>A p-value can be computed for the corresponding absolute value of t-statistic (|t|).<\/p>\n<p>If the p-value is inferior or equal to the significance level 0.05, we can reject the null hypothesis and accept the alternative hypothesis. In other words, we can conclude that the mean values of group A and B are significantly different.<\/p>\n<\/div>\n<div class=\"warning\">\n<p>Note that, the Welch t-test is considered as the safer one. Usually, the results of the <strong>classical student\u2019s t-test<\/strong> and the <strong>Welch t-test<\/strong> are very similar unless both the group sizes and the standard deviations are very different.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"paired-t-test\" class=\"section level2\">\n<h2>Paired t-test formula<\/h2>\n<p>The <strong>paired t-test<\/strong> is used to compare the means of two related groups of samples.<\/p>\n<p>The procedure of the paired t-test analysis is as follow:<\/p>\n<ol style=\"list-style-type: decimal;\">\n<li>Calculate the difference (<span class=\"math inline\">\\(d\\)<\/span>) between each pair of value<\/li>\n<li>Compute the mean (<span class=\"math inline\">\\(m\\)<\/span>) and the standard deviation (<span class=\"math inline\">\\(s\\)<\/span>) of <span class=\"math inline\">\\(d\\)<\/span><\/li>\n<li>Compare the average difference to 0. If there is any significant difference between the two pairs of samples, then the mean of d (<span class=\"math inline\">\\(m\\)<\/span>) is expected to be far from 0.<\/li>\n<\/ol>\n<p>The paired t-test statistics value can be calculated using the following formula:<\/p>\n<p><span class=\"math display\">\\[<br \/>\nt = \\frac{m}{s\/\\sqrt{n}}<br \/>\n\\]<\/span><\/p>\n<p>where,<\/p>\n<ul>\n<li><code>m<\/code> is the mean differences<\/li>\n<li><code>n<\/code> is the sample size (i.e., size of d).<\/li>\n<li><code>s<\/code> is the standard deviation of d<\/li>\n<\/ul>\n<p>We can compute the p-value corresponding to the absolute value of the t-test statistics (|t|) for the degrees of freedom (df): <span class=\"math inline\">\\(df = n - 1\\)<\/span>.<\/p>\n<div class=\"success\">\n<p>If the p-value is inferior or equal to 0.05, we can conclude that the difference between the two paired samples are significantly different.<\/p>\n<\/div>\n<\/div>\n<div id=\"related-article\" class=\"section level2\">\n<h2>Related article<\/h2>\n<p><a href=\"\/?p=10861\">T-test in R<\/a><\/p>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.<\/p>\n","protected":false},"author":1,"featured_media":7979,"parent":0,"menu_order":74,"comment_status":"open","ping_status":"closed","template":"","class_list":["post-11662","dt_lessons","type-dt_lessons","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>T-Test Formula : Excellent Reference You Will Love - Datanovia<\/title>\n<meta name=\"description\" content=\"Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"T-Test Formula : Excellent Reference You Will Love - Datanovia\" \/>\n<meta property=\"og:description\" content=\"Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/\",\"name\":\"T-Test Formula : Excellent Reference You Will Love - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg\",\"datePublished\":\"2019-12-25T16:32:03+00:00\",\"description\":\"Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg\",\"width\":1024,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lessons\",\"item\":\"https:\/\/www.datanovia.com\/en\/lessons\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"T-Test Formula\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"name\":\"Datanovia\",\"description\":\"Data Mining and Statistics for Decision Support\",\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.datanovia.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\",\"name\":\"Datanovia\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"width\":98,\"height\":99,\"caption\":\"Datanovia\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"T-Test Formula : Excellent Reference You Will Love - Datanovia","description":"Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/","og_locale":"en_US","og_type":"article","og_title":"T-Test Formula : Excellent Reference You Will Love - Datanovia","og_description":"Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.","og_url":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/","og_site_name":"Datanovia","og_image":[{"width":1024,"height":512,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/","url":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/","name":"T-Test Formula : Excellent Reference You Will Love - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg","datePublished":"2019-12-25T16:32:03+00:00","description":"Describes the t-test formula for one-sample, two-independent samples and paired samples t-test.","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_6810.jpg","width":1024,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/lessons\/t-test-formula\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"Lessons","item":"https:\/\/www.datanovia.com\/en\/lessons\/"},{"@type":"ListItem","position":3,"name":"T-Test Formula"}]},{"@type":"WebSite","@id":"https:\/\/www.datanovia.com\/en\/#website","url":"https:\/\/www.datanovia.com\/en\/","name":"Datanovia","description":"Data Mining and Statistics for Decision Support","publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanovia.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanovia.com\/en\/#organization","name":"Datanovia","url":"https:\/\/www.datanovia.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","width":98,"height":99,"caption":"Datanovia"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/"}}]}},"multi-rating":{"mr_rating_results":[]},"_links":{"self":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/11662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons"}],"about":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/types\/dt_lessons"}],"author":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/comments?post=11662"}],"version-history":[{"count":0,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/dt_lessons\/11662\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/7979"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=11662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}