
The following code shows how to perform this two sample t-test in R: #define vector of turtle weights for each sample To test this, we collect a simple random sample of turtles from each species with the following weights: Example 2: Two Sample t-test in RĪ two sample t-test is used to test whether or not the means of two populations are equal.įor example, suppose we want to know whether or not the mean weight between two different species of turtles is equal.
This means we do not have sufficient evidence to say that the mean weight of this species of turtle is different from 310 pounds. 05, we fail to reject the null hypothesis.
Since the p-value of the test (0.139) is not less than.
95% confidence interval for true mean:. The following code shows how to perform this one sample t-test in R: #define vector of turtle weights We go out and collect a simple random sample of turtles with the following weights: Example 1: One Sample t-test in RĪ one sample t-test is used to test whether or not the mean of a population is equal to some value.įor example, suppose we want to know whether or not the mean weight of a certain species of some turtle is equal to 310 pounds. The following examples show how to use this function in practice. conf.level: The confidence level to use. var.equal: Whether to assume the variances are equal between the samples. paired: Whether to perform a paired t-test or not. alternative: The alternative hypothesis of the test. Mu = 0, paired = FALSE, var.equal = FALSE, We can use the t.test() function in R to perform each type of test: #one sample t-testĪlternative = c(" two.sided", " less", " greater"), This tutorial explains how to perform the following hypothesis tests in R: A hypothesis test is a formal statistical test we use to reject or fail to reject some statistical hypothesis.