{"id":605,"date":"2015-08-01T13:58:04","date_gmt":"2015-08-01T12:58:04","guid":{"rendered":"http:\/\/pcool.dyndns.org:8080\/statsbook\/?page_id=605"},"modified":"2025-07-03T11:00:57","modified_gmt":"2025-07-03T10:00:57","slug":"non-parametric-tests-2","status":"publish","type":"page","link":"https:\/\/pcool.dyndns.org\/index.php\/non-parametric-tests-2\/","title":{"rendered":"Parametric Tests"},"content":{"rendered":"\n<p>Parametric tests can <strong><em>only<\/em><\/strong> be used if the data conform a  <a href=\"https:\/\/pcool.dyndns.org\/index.php\/normal-distribution\/\" data-type=\"page\" data-id=\"578\">Normal distribution<\/a> (or any other known distribution). Therefore, the data need to be <a href=\"https:\/\/pcool.dyndns.org\/index.php\/data-types\/\" data-type=\"page\" data-id=\"355\">continuous<\/a>. However, not all continuous data conform to a Normal distribution and data could well be <a href=\"https:\/\/pcool.dyndns.org\/index.php\/other-distributions\/\" data-type=\"page\" data-id=\"581\">skewed<\/a>.<\/p>\n\n\n\n<p>Often, we do not know how data are distributed and it is difficult to tell from our sample what the distribution of data is. The distribution could be Normal; but we are not sure. It this case we can use a statistical test to test whether the data is normally distributed or not. There are several test described to <strong><em><a href=\"https:\/\/pcool.dyndns.org\/index.php\/tests-for-normality\/\" data-type=\"page\" data-id=\"958\">test for Normality<\/a><\/em><\/strong>. Examples include the Shapiro-Wilk test, Kolmogorov-Smirnov test and Quantile-Quantile plots.<\/p>\n\n\n\n<p>Provided data are Normally distributed and the sample size is large (&gt;50) we can use the Normal distribution itself and read from the graph. Usually, we perform a <strong><em>two sided<\/em><\/strong> test. This means that the alternate hypothesis could be bigger <strong><em>or<\/em><\/strong> smaller than the null hypothesis. Consequently, we have to \u2018share\u2019 the 5% between the two tail ends of the curve (2.5% at each tail end):<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"311\" height=\"201\" src=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/twosided.png\" alt=\"\" class=\"wp-image-3863\" srcset=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/twosided.png 311w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/twosided-300x194.png 300w\" sizes=\"auto, (max-width: 311px) 100vw, 311px\" \/><\/figure>\n\n\n\n<p>It should be noted that this is plus or minus twice the standard deviation from the mean. So, if the value of the <strong><a href=\"https:\/\/pcool.dyndns.org\/index.php\/p-value\/\" data-type=\"page\" data-id=\"947\">test statistic<\/a> <\/strong>lies in each of the two dark areas on the graph; we feel this is very unlikely to be due to chance and the null hypothesis is rejected in favour of the alternate hypothesis.<\/p>\n\n\n\n<p>Occasionally, it is appropriate to do <strong>one sided<\/strong> testing:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"278\" height=\"179\" src=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/onesided.png\" alt=\"\" class=\"wp-image-3288\"\/><\/figure>\n\n\n\n<p><strong>t-Test<\/strong><\/p>\n\n\n\n<p>If the sample size is large (&gt; 50), we can use the Normal distribution and read from graphs \/ tables. However, it is unusual to have such large sample sizes and often sample sizes are much smaller (around 20 to 30).Consequently, a &#8216;correction&#8217; has to be made for the small sample size. This can be done using the <strong><em>t-test<\/em><\/strong>.<\/p>\n\n\n\n<p>As example we use the <a href=\"https:\/\/pcool.dyndns.org:\/wp-content\/data_files\/skinfold.rda\" target=\"_blank\" rel=\"noreferrer noopener\">skinfold.rda<\/a> data on the thickness of the skinfold in patients with and without cancer. For now, let us assume we have demonstrated that it is reasonable to model the data with a <a href=\"https:\/\/pcool.dyndns.org\/index.php\/normal-distribution\/\" data-type=\"page\" data-id=\"578\">Normal distribution<\/a> (<a href=\"https:\/\/pcool.dyndns.org\/index.php\/tests-for-normality\/\" data-type=\"page\" data-id=\"958\">test for Normality<\/a>) and the t-test can be used to analyse the data. A mathematical description of the t-test is beyond the scope of this book. Suffice to say that the t-test corrects for the smaller sample size with a \u2018correction factor\u2019.<\/p>\n\n\n\n<p>To perform a t-test it is necessary to have a continuous outcome variable and a <a href=\"https:\/\/pcool.dyndns.org\/index.php\/data-types\/\" data-type=\"page\" data-id=\"355\">nominal<\/a> grouping variable.<\/p>\n\n\n\n<p>To perform an <strong>unpaired t-test<\/strong> (a paired t-test would be before and after a treatment; so the data are paired)in R:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><span style=\"color: #ff0000;\"><em>t.test(Skinfold~Group,data=skinfold)<\/em><\/span>\n<span style=\"color: #0000ff;\"><em> &nbsp;Welch Two Sample t-test<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>data:&nbsp; Skinfold by Group<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>t = -2.7653, df = 26.968, p-value = 0.01013<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>alternative hypothesis: true difference in means is not equal to 0<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>95 percent confidence interval:<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>&nbsp;-3.0475746 -0.4513143<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>sample estimates:<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>&nbsp;&nbsp; mean in group Cancer mean in group No Cancer <\/em><\/span>\n<span style=\"color: #0000ff;\"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.955556&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.705000&nbsp;<\/em><\/span><\/code><\/pre>\n\n\n\n<p>The computer calculates the p value using the t-test:<\/p>\n\n\n\n<p>p = 0.010<\/p>\n\n\n\n<p>Therefore, the probability that the test statistic takes a more extreme value is very small and unlikely due to chance (statistically significant). Consequently, the null hypothesis is rejected in favour of the alternate hypothesis. It is concluded that there is a difference in skin fold thickness in patients with cancer and that their nutrition is poorer.<\/p>\n\n\n\n<p>In the example above, the t-test was performed on unpaired data. A t-test can also be performed on paired samples; before and after an intervention or treatment. If the data are dependent \/ related, use a <strong><em>paired t-test<\/em><\/strong>. Otherwise, use an <strong>unpaired t-test<\/strong>. An example of dependent data is the range of movement in the knee before and after a total knee replacement. We have two groups of data: range of movement before and after total knee replacement. The two groups are dependent and provided the data conform a Normal distribution; it is reasonable to use a paired t-test.<\/p>\n\n\n\n<p>Back to the example; on the basis of the t-test, it seems reasonable to reject the null hypothesis (there is no difference in skinfold thickness between cancer and non cancer patients) in favour of the alternate hypothesis and  conclude that there is a difference in skinfold thickness (and therefore nutritional status). <strong>However<\/strong>, we may not have been correct in using a t-test, as it has not been demonstrated the data can reasonably be modelled with a Normal distribution. <a href=\"https:\/\/pcool.dyndns.org\/index.php\/tests-for-normality\/\" data-type=\"page\" data-id=\"958\">To check Normality<\/a> of all the skinfold thickness data:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><span style=\"color: #ff0000;\"><em>shapiro.test(skinfold$Skinfold)<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>&nbsp;&nbsp; &nbsp;Shapiro-Wilk normality test<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>data:&nbsp; skinfold$Skinfold<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>W = 0.8519, p-value = 0.0008328<\/em><\/span><\/code><\/pre>\n\n\n\n<p class=\"is-style-text-annotation is-style-text-annotation--1\">Please note the capital S in the Skinfold variable within the skinfold data frame (with lower case s)<\/p>\n\n\n\n<p>The p value is significant, suggesting the data can&#8217;t be modelled with a Normal distribution. However, only the data of both groups together (Cancer and Non Cancer) has been examined for Normality. But we have just demonstrated there is a statistical difference between the two groups and they are <em><strong>not<\/strong><\/em> likely to belong to the same distribution (p&lt;0.05)! In addition, Normality should be tested in both groups separately:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><span style=\"color: #ff0000;\"><em>shapiro.test(skinfold$Skinfold<strong>&#91;which(skinfold$Group =='No Cancer')]<\/strong>)<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>&nbsp; &nbsp;Shapiro-Wilk normality test<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>data:&nbsp; skinfold$Skinfold&#91;which(skinfold$Group == \"No Cancer\")]<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>W = 0.8856, p-value = 0.0223<\/em><\/span><\/code><\/pre>\n\n\n\n<p>and<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><em><span style=\"color: #ff0000;\">shapiro.test(skinfold$Skinfold<strong>&#91;which(skinfold$Group =='Cancer')]<\/strong>)<\/span><\/em>\n<span style=\"color: #0000ff;\"><em>&nbsp;&nbsp; &nbsp;Shapiro-Wilk normality test<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>data:&nbsp; skinfold$Skinfold&#91;which(skinfold$Group == \"Cancer\")]<\/em><\/span>\n<span style=\"color: #0000ff;\"><em>W = 0.8047, p-value = 0.02309<\/em><\/span><\/code><\/pre>\n\n\n\n<p class=\"is-style-text-annotation is-style-text-annotation--2\">The [which(skinfold$Group ==&#8217;No Cancer&#8217;)] part only selects the &#8216;No Cancer&#8217; patients from the data frame<\/p>\n\n\n\n<p>In addition, <a href=\"https:\/\/pcool.dyndns.org\/index.php\/tests-for-normality\/\" data-type=\"page\" data-id=\"958\">quantile-quantile plots<\/a> could be help:<\/p>\n\n\n\n<p>For the &#8216;No Cancer&#8217; group:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><span style=\"color: #ff0000;\"><em>qqnorm(skinfold$Skinfold&#91;which(skinfold$Group =='No Cancer')])<\/em><\/span>\n<span style=\"color: #ff0000;\"><em>qqline(skinfold$Skinfold&#91;which(skinfold$Group =='No Cancer')],lty=2)<\/em><\/span><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq1-1024x768.png\" alt=\"\" class=\"wp-image-3627\" srcset=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq1-1024x768.png 1024w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq1-300x225.png 300w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq1-768x576.png 768w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq1.png 1355w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>and for the &#8216;Cancer&#8217; group:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><em><span style=\"color: #ff0000;\">qqnorm(skinfold$Skinfold&#91;which(skinfold$Group =='Cancer')])<\/span><\/em>\n<em><span style=\"color: #ff0000;\">qqline(skinfold$Skinfold&#91;which(skinfold$Group =='Cancer')],lty=2)<\/span><\/em><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq2-1024x768.png\" alt=\"\" class=\"wp-image-3628\" srcset=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq2-1024x768.png 1024w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq2-300x225.png 300w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq2-768x576.png 768w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/skinfoldqq2.png 1355w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The number of patients in the \u2018Cancer\u2019 group is very small (9), but both groups fail the <a href=\"https:\/\/pcool.dyndns.org\/index.php\/tests-for-normality\/\" data-type=\"page\" data-id=\"958\">Normality tests<\/a>. It is therefore more appropriate to use a <a href=\"https:\/\/pcool.dyndns.org\/index.php\/non-parametric-tests\/\" data-type=\"page\" data-id=\"594\">non parametric test<\/a>, in which it is not a requirement for data to conform a Normal distribution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parametric tests can only be used if the data conform a Normal distribution (or any other known distribution). Therefore, the data need to be continuous. However, not all continuous data conform to a Normal distribution and data could well be skewed. Often, we do not know how data are distributed and it is difficult to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-605","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages\/605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/comments?post=605"}],"version-history":[{"count":5,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages\/605\/revisions"}],"predecessor-version":[{"id":4858,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages\/605\/revisions\/4858"}],"wp:attachment":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/media?parent=605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}