Ch 18: One sample t-test
The following examples are based on the data, soc510hw2.csv in which female, married, and wage variables are found. Note that females are coded 1 and males are coded 0. How to read a data file into R is found here.
Two-tail t-test
Two-tail t-test of wage.
Ho: Mean wage is equal to 13.
Ha: Mean wage is not equal to 13.> t.test(wage, mu=13) One Sample t-test data: wage t = 36.2368, df = 82735, p-value < 2.2e-16 alternative hypothesis: true mean is not equal to 13 95 percent confidence interval: 14.07280 14.19549 sample estimates: mean of x 14.13414
One-tail t-test
Right side 1-tail t-test of wage.
Ho: Mean wage is not greater than 13.
Ha: Mean wage is greater than 13.> t.test(wage, mu=13, alternative="greater") One Sample t-test data: wage t = 36.2368, df = 82735, p-value < 2.2e-16 alternative hypothesis: true mean is greater than 13 95 percent confidence interval: 14.08266 Inf sample estimates: mean of x 14.13414
Left side 1-tail t-test of wage.
Ho: Mean wage is not less than 16.
Ha: Mean wage is less than 16.> t.test(wage, mu=16, alternative="less")
[ Going back to Using R: Index ]