Hypothesis Testing with R

hypothesis tests for population means are done in R using the command "t.test".

One-sample hypothesis test

Let x represents a sample collected from a normal population with unknown mean and standard deviation. We want to test if the population mean is equal to 9, at significance level 5%.

The hypotheses are 

>x= c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,
+            + 8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,
+            + 11.3, 11.9)                                                              # Entering the data
>t.test(x-9,alternative="two.sided",conf.level=0.95)                                    # Performing the t-test

 
One Sample t-test

data:  x - 9
t = -0.3569, df = 23, p-value = 0.3622
alternative hypothesis: true mean is less than 0
95 percent confidence interval:
      -Inf 0.3960916
sample estimates:
 mean of x 
-0.1041667 

Interpretation of the result

The P-value (0.3622) is greater than the significance level 5% (1-0.95), so we conclude that the null hypothesis that the mean of this population is 9 is plausible.

Two-sample hypothesis test

If we are interested in finding the confidence interval for the difference of two population means, the R-command "t.test" is also to be used.
The article "Measuring and Understanding the Aging of Kraft Insulating Paper in Power Transformers" (IIEE Electrical Insul. Mag., 1996:28-34), contained observations on degree of polymerization for paper specimens for which viscosity times concentration fell in a certain middle range x=(418,421,421,422,425,427,431,434,437,439,446,447,448,453,454,463,465) and and higher range y=(429,430,430,431,36,437,440,441,445,446,447).

We are interested in testing observations middle range and higher viscosity are from  populations with different means, at significance level 5%.

The hypotheses are 

>x=c(418,421,421,422,425,427,431,434,437,439,446,447,448,453,454,463,465)          # Entering the data into the R-workspace
>y=c(429,430,430,431,36,437,440,441,445,446,447)
>test2<-t.test(x,y,alternative="two.sided",mu=0,var.equal=F,conf.level=0.95)       # Performing a t-test procedure, containing a confidence interval computation

Welch Two Sample t-test

data:  x and y
t = 1.0123, df = 10.202, p-value = 0.3348
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -44.46343 118.86984
sample estimates:
mean of x mean of y 
 438.2941  401.0909 

Interpretation of the result
The P-value ( 0.3348) is greater than the significance level 5% (1-0.95), so we conclude that the null hypothesis that the population means are equal is plausible.