BPS651 Exercise V
BPS651 Exercise V
BPS651 Exercise V
Laboratory Exercise V
Course BPS651 Research Methodology
R.S. Rajput
Assistant Professor Computer Science
T Test
A t-test is a statistical hypothesis test, in which the test statistic follows a Student's t-distribution
if the null hypothesis is supported. It can be used to determine if two sets of data are
significantly different from each other, and is most commonly applied when the test statistic
would follow a normal distribution if the value of a scaling term in the test statistic were known.
t-test Function in R
The R function t.test() can be used to perform both one and two sample t-tests on vectors of
data. The function contains a variety of options and can be called as follows:
Here
y is an optional numeric vector of data values. If y is excluded, the function performs a onesample t-test on the data contained in x, if it is included it performs a two-sample t-tests
using both x and y.
The option mu provides a number indicating the true value of the mean (or difference in
means if you are performing a two sample test) under the null hypothesis.
The option alternative is a character string specifying the alternative hypothesis, and must
be one of the following: "two. sided" (which is the default), "greater" or "less" depending
on whether the alternative hypothesis is that the mean is different than, greater than or less
than mu, respectively. For example the following call:
Page 1
performs a one sample t-test on the data contained in x where the null hypothesis is that =10
and the alternative is that <10.
The option paired indicates whether or not you want a paired t-test (TRUE = yes and FALSE
= no). If you leave this option out it defaults to FALSE.
The option var.equal is a logical variable indicating whether or not to assume the two
variances as being equal when performing a two-sample t-test. If TRUE then the pooled
variance is used to estimate the variance otherwise the Welch (or Satterthwaite)
approximation to the degrees of freedom is used. If you leave this option out it defaults to
FALSE.
The option conf.level determines the confidence level of the reported confidence interval
One-sample t-test
Example: An outbreak of Salmonella-related illness was attributed to ice cream produced at a
certain factory. Scientists measured the level of Salmonella in 9 randomly sampled batches of
ice cream. The levels (in MPN/g) were: 0.593, 0.142, 0.329, 0.691, 0.231, 0.793, 0.519, 0.392,
0.418 is there evidence that the mean level of Salmonella in the ice cream is greater than 0.3
MPN/g?
Solution: Let be the mean level of Salmonella in all batches of ice cream. Here the hypothesis of
interest can be expressed as:
H0: = 0.3
H1: > 0.3
Hence, we will need to include the options alternative="greater", mu=0.3. Below is the relevant
R-code:
>x=c(0.593,0.142,0.329,0.691,0.231,0.793,0.519,0.392,0.418)
>t.test(x, alternative="greater", mu=0.3)
Page 2
From the output we see that the p-value = 0.029. Hence, there is moderately strong evidence
that the mean Salmonella level in the ice cream is above 0.3 MPN/g.
Exercise-17
Ten pieces of cloth each of 100 square meters were selected and number of weaving defects
were counted as given below. Test whether average number of weaving defects on such a cloth
is less than 5. (Given that table value= t(9,0.05)=1.833).
4, 0, 3, 3, 2, 3, 5, 8, 6, 6.
Exercise-18
Daily protein intake ( in gm) by an adult during a fortnight was reported as 48.1, 52.1, 52.0, 48.4,
49.4, 52.0, 46.6, 49.8, 46.4, 50.2, 48.8, 46.5, 50.0, 51.4 and 48.0 .Can we say that on an average
daily protein intake by that adult is 50 gm ?(Given that table value= t(14, 0.05/2)=2.145).
Exercise-19
Over the years an instructor has observed that on an average students get 11.5 marks in first
pre-final examination. Marks secured by 16 students of a particular batch in the first pre-final
examination were 9.5, 10.0, 14.5, 13.5, 14.0, 15.0, 10.5, 12.2, 11.0, 10.5, 14.0, 12.0, 13.5, 12.0,
14.0 and 15.0 . Can we conclude that this is a superior batch ? (Given that table value= t(15,
0.05) = 1.753).
Exercise-20
The weight of a canned food product is specified as 500 gm. For a random sample of 20 cans the
weights were observed as 480, 475, 510, 500, 505, 495, 498, 504, 490, 485, 505, 492, 490, 495,
515, 504, 486, 494, 496 and 491. Test whether on an average the weight is as per specification.
(Given that table value= t(19,0.05/2)=2.093) .
Two-sample t-tests
Example: 6 subjects were given a drug (treatment group) and an additional 6 subjects a placebo
(control group). Their reaction time to a stimulus was measured (in ms). We want to perform a
two-sample t-test for comparing the means of the treatment and control groups.
Let 1 be the mean of the population taking medicine and 2 the mean of the untreated
population. Here the hypothesis of interest can be expressed as:
H0: 1-2=0
Ha: 1-2<0
Page 3
Page 4
Page 5