class: center, middle, inverse, title-slide # Inference Procedures with R ## RSS MODULE 3 : Basic statistical methods - Question 2 --- <style type="text/css"> pre { background: #ADD8E6; max-width: 100%; overflow-x: scroll; } </style> ### Weight Gain Example Twenty cows were used in an experiment to compare two types of feed, Feed A and Feed B. * Half of the cows, chosen at random, were fed with Feed A over a certain period of time and the other half with Feed B. * In fact two of the cows on Feed B were wrongly fed for part of the period and they had to be removed from the experiment. * The gains in weight, in pounds, of the remaining cows over the period of the experiment are listed below. |Feed|Weight Gain| |:-----:|:-----------------------| |Feed A |30 26 30 19 25 37 27 38 26 31| |Feed B |40 34 28 29 26 36 28 37| * The corresponding sample means and variances are also given. | | sample mean | sample variance | | :---------: | |:---------: :---------: | | Feed A | 28.9 | 32.1 | | Feed B | 32.3 | 26.5 | --- ### Inputtin Data into R Environment ```r FeedA <- c(30, 26, 30, 19, 25, 37, 27, 38, 26, 31) FeedB <- c(40, 34, 28, 29, 26, 36, 28, 37) ``` ```r mean(FeedA);var(FeedA) ``` ``` ## [1] 28.9 ``` ``` ## [1] 32.1 ``` ```r mean(FeedB);var(FeedB) ``` ``` ## [1] 32.25 ``` ``` ## [1] 26.5 ``` --- ***Questions from RSS Exam Paper - Theoretical components not covered here*** <hline> ### Exercises (i) Defining any unknown parameters, write down a statistical model for the distributions of weight gains in the two populations of cows given the two feeds, assuming that the variances of these two distributions are equal. (ii) Carefully specifying your hypotheses, test at the 5% significance level whether there is a difference between the mean weight increases for the two feeds. (iii) It is now required to test at the 5% significance level the assumption that the variances of the two weight gain distributions are equal. State any adjustments that are needed to the model in part (i), carefully specify the hypotheses to be tested, carry out the test and give your conclusions. --- ### Two sample t-test ```r t.test(FeedA,FeedB,var.equal=TRUE) ``` ``` ## ## Two Sample t-test ## ## data: FeedA and FeedB ## t = -1.297, df = 16, p-value = 0.213 ## alternative hypothesis: true difference in means is not equal to 0 ## 95 percent confidence interval: ## -8.825453 2.125453 ## sample estimates: ## mean of x mean of y ## 28.90 32.25 ``` --- ### Test the assumption of equality of variance ```r var.test(FeedA,FeedB) ``` ``` ## ## F test to compare two variances ## ## data: FeedA and FeedB ## F = 1.2113, num df = 9, denom df = 7, p-value = 0.8186 ## alternative hypothesis: true ratio of variances is not equal to 1 ## 95 percent confidence interval: ## 0.2511437 5.0839697 ## sample estimates: ## ratio of variances ## 1.211321 ``` --- ### Welch Two Sample t-test Comparing sample means in the case when the assumption of equality of variance can not be accepted. The assumption is actually met as per previous result, but it is worth inspecting the results to compare with the two-sample t-test. ```r t.test(FeedA,FeedB,var.equal=FALSE) ``` ``` ## ## Welch Two Sample t-test ## ## data: FeedA and FeedB ## t = -1.3117, df = 15.685, p-value = 0.2085 ## alternative hypothesis: true difference in means is not equal to 0 ## 95 percent confidence interval: ## -8.77293 2.07293 ## sample estimates: ## mean of x mean of y ## 28.90 32.25 ``` ``` ---