sing the data on 15 workers, construct an exact 95% confidence interval for \(\mu\).

setwd("C:/Users/cpwer/Downloads/Lab0")

library(readxl)
Wage=read_excel("Wage.xlsx")
summary(Wage)
##      Worker      Wage before       Wage after   
##  Min.   : 1.0   Min.   : 7.750   Min.   : 7.75  
##  1st Qu.: 4.5   1st Qu.: 8.875   1st Qu.: 9.25  
##  Median : 8.0   Median :10.000   Median :10.00  
##  Mean   : 8.0   Mean   :10.167   Mean   :10.41  
##  3rd Qu.:11.5   3rd Qu.:11.325   3rd Qu.:11.50  
##  Max.   :15.0   Max.   :12.650   Max.   :13.10
D_i=Wage$`Wage after`-Wage$`Wage before`

confint=t.test(D_i, conf.level=0.95)$conf.int
print(confint)
## [1] -0.009684686  0.489684686
## attr(,"conf.level")
## [1] 0.95
  1. Test the null hypothesis from part (ii) against the stated alternative at the 5% and 1% levels.
test95=t.test(D_i, mu=0, conf.level=0.95, alternative="greater")
summary(test95)
##             Length Class  Mode     
## statistic   1      -none- numeric  
## parameter   1      -none- numeric  
## p.value     1      -none- numeric  
## conf.int    2      -none- numeric  
## estimate    1      -none- numeric  
## null.value  1      -none- numeric  
## stderr      1      -none- numeric  
## alternative 1      -none- character
## method      1      -none- character
## data.name   1      -none- character
print(test95)
## 
##  One Sample t-test
## 
## data:  D_i
## t = 2.0616, df = 14, p-value = 0.02916
## alternative hypothesis: true mean is greater than 0
## 95 percent confidence interval:
##  0.03495762        Inf
## sample estimates:
## mean of x 
##      0.24
test1=t.test(D_i, mu=0, conf.level=0.99, alternative="greater")
summary(test1)
##             Length Class  Mode     
## statistic   1      -none- numeric  
## parameter   1      -none- numeric  
## p.value     1      -none- numeric  
## conf.int    2      -none- numeric  
## estimate    1      -none- numeric  
## null.value  1      -none- numeric  
## stderr      1      -none- numeric  
## alternative 1      -none- character
## method      1      -none- character
## data.name   1      -none- character
print(test1)
## 
##  One Sample t-test
## 
## data:  D_i
## t = 2.0616, df = 14, p-value = 0.02916
## alternative hypothesis: true mean is greater than 0
## 99 percent confidence interval:
##  -0.06552967         Inf
## sample estimates:
## mean of x 
##      0.24

Q4 (iv) Obtain the p-value for the test in part (iii).

Pvalue=test95$p.value
print(Pvalue)
## [1] 0.02916138