3. Lets assess normality of both the x and y variables.
# combine 4 plots into 1 to assess normality of both variables par(mfrow=c(2,2)) hist(x) qqnorm(x) qqline(x) hist(y) qqnorm(y) qqline(y)
SARAH.. this is the code to get numerator, denominator.. test statistic..
# summary statistics mean.x = mean(x) n.x = length(x) sd.x = sd(x) var.x = sd.x^2 mean.y = mean(y) n.y = length(y) sd.y = sd(y) var.y = sd.y^2 # calculate test statistic point.estimate = mean.y - mean.x se = sqrt((var.x/n.x) + (var.y/n.y)) test.stat = point.estimate/se
### USING JUST t.test() function .. u can get test.statistic, df, and p-value
> t.test(y, x, alternative = "less") Welch Two Sample t-test data: y and x t = -0.418, df = 15.067, p-value = 0.3409 alternative hypothesis: true difference in means is less than 0 95 percent confidence interval: -Inf 11.44782 sample estimates: mean of x mean of y 94.71429 98.30000
CONCLUSION: The p-value is 0.34.
Calculate the 90% onfidence interval.
> t.test(y, x, + conf.level = 0.90) Welch Two Sample t-test data: y and x t = -0.418, df = 15.067, p-value = 0.6818 alternative hypothesis: true difference in means is not equal to 0 90 percent confidence interval: -18.61925 11.44782 sample estimates: mean of x mean of y 94.71429 98.30000
Conclusion: Based on the data, I can be 95% confident that the difference in the mean of population 1 and the mean of population 2 falls between -18.62 and 11.45.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.