Example: p Value and Significance Level
Example: p Value and Significance Level
Introduction
Here we examine how significance levels and p values interact when you use the TTest function. For a given dataset, the pvalue does not depend on the choice of significance level. However, the conclusion of the test, i.e., whether to reject the null hypothesis or not, does depend on the combination of pValue and significance test.
Sample data sets
Here we take the example data from Lesson 27 and create additional datasets that have slightly different means. We will used these to test how the pValue and confidence limit interact. As the mean gets farther from the test value (1000), the pvalue will decrease.
In[]:=
sample={1002.9,997.8,998.0,1000.1,1003.5,1000.7,1006.4,996.4,1000.3,1005.6,1002.3,1004.6,1000.0,1000.4,1003.9,1002.2,1003.4,1001.3,998.5,1002.9,999.7,1004.3,999.1,1001.8,1001.3};
In[]:=
sample1=sample+0.5;sample2=sample+.4;sample3=sample+.3;sample4=sample+0.2;sample5=sample+0.1;
In[]:=
sample6=sample-0.2;sample7=sample-0.5;sample8=sample-0.75;
In[]:=
samples={sample,sample1,sample2,sample3,sample4,sample5,sample6,sample7,sample8};
In[]:=
means=Table[Mean[samples[[n]]],{n,1,9}]
Out[]=
{1001.5,1002.,1001.9,1001.8,1001.7,1001.6,1001.3,1001.,1000.75}
TTest results with default 0.05 significance level
We explicitly declare the default significance level of 0.05
In[]:=
Table[{Mean[samples[[n]]],TTest[samples[[n]],1000,{"PValue","TestConclusion"},SignificanceLevel->0.05]},{n,6,9}]
Out[]=
{{1001.6,{0.00436405,The null hypothesis that the mean of the population is equal to 1000 is rejected at the 5. percent level based on the T test.}},{1001.3,{0.0173587,The null hypothesis that the mean of the population is equal to 1000 is rejected at the 5. percent level based on the T test.}},{1001.,{0.0612157,The null hypothesis that the mean of the population is equal to 1000 is not rejected at the 5. percent level based on the T test.}},{1000.75,{0.154277,The null hypothesis that the mean of the population is equal to 1000 is not rejected at the 5. percent level based on the T test.}}}
From the above, when the p value goes below 0.05, then we reject the null hypothesis.
TTest results with 0.01 Significance level
In[]:=
Table[{Mean[samples[[n]]],TTest[samples[[n]],1000,{"PValue","TestConclusion"},SignificanceLevel->0.01]},{n,6,9}]
Out[]=
{{1001.6,{0.00436405,The null hypothesis that the mean of the population is equal to 1000 is rejected at the 1. percent level based on the T test.}},{1001.3,{0.0173587,The null hypothesis that the mean of the population is equal to 1000 is not rejected at the 1. percent level based on the T test.}},{1001.,{0.0612157,The null hypothesis that the mean of the population is equal to 1000 is not rejected at the 1. percent level based on the T test.}},{1000.75,{0.154277,The null hypothesis that the mean of the population is equal to 1000 is not rejected at the 1. percent level based on the T test.}}}
The pvalues do not change when you change the significance level. At the significance level of 0.01 the null hypothesis is rejected when p drops below 0.01.