1 Question 2.24

Two machines are used for filling plastic bottles with a net volume of 16.0 ounces. The filling processes can be assumed to be normal, with standard deviations of \(\sigma_1 = 0.015\) and \(\sigma_2 = 0.018\). The quality engineering department suspects that both machines fill to the same net volume, whether or not this volume is 16.0 ounces. An experiment is performed by taking a random sample

(a) State the hypotheses that should be tested in this experiment.
(b) Test these hypotheses using \(\alpha = 0.05\). What are your conclusions?
(c) Find the P-value for this test.
(d) Find a 95 percent confidence interval on the difference in mean fill volume for the two machines

1.1 Solution - Question 2.24

Creating the Dataframe:

# Creating the Dataframe:
machine1<- c(16.03,16.04,16.05,16.05,16.02,16.01,15.96,15.98,16.02,15.99)
machine2 <- c(16.02,15.97,15.96,16.01,15.99,16.03,16.04,16.02,16.01,16.00)
machines <- data.frame(machine1,machine2)
machines
##    machine1 machine2
## 1     16.03    16.02
## 2     16.04    15.97
## 3     16.05    15.96
## 4     16.05    16.01
## 5     16.02    15.99
## 6     16.01    16.03
## 7     15.96    16.04
## 8     15.98    16.02
## 9     16.02    16.01
## 10    15.99    16.00

1.1.1 Section (a)

(a) State the hypotheses that should be tested in this experiment.

The hypothesis to test are:

  • \(H_0: \mu_{\text{Machine1}} = \mu_{\text{Machine2}}\)
  • \(H_a: \mu_{\text{Machine1}} \neq \mu_{\text{Machine2}}\)

1.1.2 Section (b)

(b) Test these hypotheses using \(\alpha = 0.05\). What are your conclusions?

Checking the Variance:

# Checking the variance
var(machines$machine1)
## [1] 0.0009166667
var(machines$machine2)
## [1] 0.00065
# Plot a boxplot
boxplot(machines$machine1,machines$machine2)

Applying the Two-Sample T-Test:

# Applying the Two-Sample T-Test
t.test(x = machines$machine1,y = machines$machine2, var.equal = FALSE, alternative = "two.sided", conf.level = 0.95)
## 
##  Welch Two Sample t-test
## 
## data:  machines$machine1 and machines$machine2
## t = 0.79894, df = 17.493, p-value = 0.435
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.01635123  0.03635123
## sample estimates:
## mean of x mean of y 
##    16.015    16.005

CONCLUSIONS:

  • Since the P-Value (0.435) is greater than significance level (0.05), I fail to reject the null hypothesis. This indicates that there is no significant difference in the filling performance of the two machines.

  • The sample average for Machine 1 is 16.015

  • The sample average for Machine 2 is 16.005

  • The T-statistic value is 0.79894

1.1.3 Section (c)

(c) Find the P-value for this test.
The P-value for the T-test is 0.4347

1.1.4 Section (d)

(d) Find a 95 percent confidence interval on the difference in mean fill volume for the two machines.
The 95% confidence interval of (-0.01627, 0.03630) indicates that the estimated difference in fill volumes between the two machines could range from -0.01627 to 0.03630 with 95% confidence



2 Question 2.26

The following are the burning times (in minutes) of chemical flares of two different formulations. The design engineers are interested in both the mean and variance of the burning times.


(a) Test the hypothesis (Using Levene’s test) that the two variances are equal \(\alpha = 0.05\).

(b) Using the results of (a), test the hypothesis that the mean burning times are equal. Use \(\alpha = 0.05\). What is the P-value for this test?

2.1 Solution - Question 2.26

Creating the Dataframe:

# Creating the Dataframe:
burn_time <- c(65, 81, 57, 66, 82, 82, 67, 59, 75, 70, 64, 71, 83, 59, 65, 56, 69, 74, 82, 79)
type <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
df_burning <- data.frame(burn_time,type)
df_burning$type <- as.factor(df_burning$type)
df_burning
##    burn_time type
## 1         65    1
## 2         81    1
## 3         57    1
## 4         66    1
## 5         82    1
## 6         82    1
## 7         67    1
## 8         59    1
## 9         75    1
## 10        70    1
## 11        64    2
## 12        71    2
## 13        83    2
## 14        59    2
## 15        65    2
## 16        56    2
## 17        69    2
## 18        74    2
## 19        82    2
## 20        79    2

2.1.1 Section (a)

(a) Test the hypothesis (Using Levene’s test) that the two variances are equal \(\alpha = 0.05\).

The hypothesis to test are:

  • \(H_0: \sigma^2_{\text{Type1}} = \sigma^2_{\text{Type2}}\)
  • \(H_a: \sigma^2_{\text{Type1}} \neq \sigma^2_{\text{Type2}}\)

Using Levene’s Test to test the Hypothesis

# Using Levene’s Test to test the Hypothesis
levene.test(y = df_burning$burn_time, group = df_burning$type, location = "mean")
## 
##  Classical Levene's test based on the absolute deviations from the mean
##  ( none not applied because the location is not set to median )
## 
## data:  df_burning$burn_time
## Test Statistic = 0.0014598, p-value = 0.9699

Since the P-Value (0.9699) is greater than significance level (0.05), I fail to reject the null hypothesis.

2.1.2 Section (b)

(b) Using the results of (a), test the hypothesis that the mean burning times are equal. Use \(\alpha = 0.05\). What is the P-value for this test?

The hypothesis to test are:

  • \(H_0: \mu_{\text{Type1}} = \mu_{\text{Type2}}\)
  • \(H_a: \mu_{\text{Type1}} \neq \mu_{\text{Type2}}\)
# Applying the Two-Sample T-Test
burn_type1 <- df_burning %>% filter(type==1) %>% select(burn_time)
burn_type2 <- df_burning %>% filter(type==2) %>% select(burn_time)

t.test(x = burn_type1,y = burn_type2,var.equal=TRUE, alternative = "two.sided")
## 
##  Two Sample t-test
## 
## data:  burn_type1 and burn_type2
## t = 0.048008, df = 18, p-value = 0.9622
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -8.552441  8.952441
## sample estimates:
## mean of x mean of y 
##      70.4      70.2

CONCLUSIONS:

  • The P-values is 0.9622

  • Since the P-Value (0.9622) is greater than significance level (0.05), I fail to reject the null hypothesis. This indicates that there is no significant difference in the mean burning times.

  • The sample average for type1 is 70.4

  • The sample average for type 2 is 70.2

  • The T-statistic value is 0.048008



3 Question 2.27

An article in Solid State Technology, “Orthogonal Design for Process Optimization and Its Application to Plasma Etching” by G. Z. Yin and D. W. Jillie (May 1987) describes an experiment to determine the effect of the \(C_2F_6\) flow rate on the uniformity of the etch on a silicon wafer used in integrated circuit manufacturing. All of the runs were made in random order. Data for two flow rates are as follows:

(a) Does the \(C_2F_6\) flow rate affect average etch uniformity? Use \(\alpha = 0.05\) and Non-Parametric Method

3.1 Solution - Question 2.27

Creating the Dataframe:

# Creating the Dataframe:
f_rate125 <- c(2.7,4.6,2.6,3.0,3.2,3.8)
f_rate200 <- c(4.6,3.4,2.9,3.5,4.1,5.1)
df <- data.frame(f_rate125,f_rate200)
df
##   f_rate125 f_rate200
## 1       2.7       4.6
## 2       4.6       3.4
## 3       2.6       2.9
## 4       3.0       3.5
## 5       3.2       4.1
## 6       3.8       5.1

3.1.1 Section (a)

(a) Does the \(C_2F_6\) flow rate affect average etch uniformity? Use \(\alpha = 0.05\) and Non-Parametric Method

The hypothesis to test are:

  • \(H_0: \mu_{\text{FRate_125}} = \mu_{\text{FRate_200}}\)
  • \(H_a: \mu_{\text{FRate_125}} \neq \mu_{\text{FRate_200}}\)

Applying the Non Parametric Two sample t-test

# Applying the Non Parametric Two sample t-test
wilcox.test(x = df$f_rate125, y=df$f_rate200)
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  df$f_rate125 and df$f_rate200
## W = 9.5, p-value = 0.1994
## alternative hypothesis: true location shift is not equal to 0

CONCLUSIONS:

  • The P-values is 0.1994

  • Since the P-Value (0.1994) is greater than significance level (0.05), I fail to reject the null hypothesis. This indicates that there are no statistically significant differences in the etching uniformity between the two flow rates



4 Question 2.29

Photoresist is a light-sensitive material applied to semiconductor wafers so that the circuit pattern can be imaged on to the wafer. After application, the coated wafers are baked to remove the solvent in the photoresist mixture and to harden the resist. Here are measurements of photoresist thickness (in kA) for eight wafers baked at two different temperatures. Assume that all of the runs were made in random order

(a) Is there evidence to support the claim that the higher baking temperature results in wafers with a lower mean photoresist thickness? Use \(\alpha = 0.05\).
(b) What is the P-value for the test conducted in part (a)?
(c) Find a 95 percent confidence interval on the difference in means. Provide a practical interpretation of this interval.
(e) Check the assumption of normality of the photoresist thickness.
(f) Find the power of this test for detecting an actual difference in means of 2.5 kA.

4.1 Solution - Question 2.29

Creating the Dataframe:

#Creating the Dataframe:
t95 <- c(11.176, 7.089, 8.097, 11.739, 11.291, 10.759, 6.467, 8.315)
t100 <- c(5.263, 6.748, 7.461, 7.015, 8.133, 7.418, 3.772, 8.963)
df <- data.frame(t95,t100)
df
##      t95  t100
## 1 11.176 5.263
## 2  7.089 6.748
## 3  8.097 7.461
## 4 11.739 7.015
## 5 11.291 8.133
## 6 10.759 7.418
## 7  6.467 3.772
## 8  8.315 8.963

4.1.1 Section (a)

(a) Is there evidence to support the claim that the higher baking temperature results in wafers with a lower mean photoresist thickness? Use \(\alpha = 0.05\).
For the t test I assume that the requirement of normality are satisfied.

Checking the Variance (using Levene’s test)

# Checking the Variance (using Levene's test)
thickness = c(t95,t100)
temp = c("t95","t95","t95","t95","t95","t95","t95","t95","t100","t100","t100","t100","t100","t100","t100","t100")
df2 <- data.frame(thickness, temp)

levene.test(y = df2$thickness, group = df2$temp, location = "mean")
## 
##  Classical Levene's test based on the absolute deviations from the mean
##  ( none not applied because the location is not set to median )
## 
## data:  df2$thickness
## Test Statistic = 2.5625, p-value = 0.1317

Since the P-value is greater than 0.05, I fail to reject the null hypothesis, indicating that the variances between the two groups are statistically similar

Now I will apply the two sample t-test

The hypothesis to test are:

  • \(H_0: \mu_{\text{T95}} = \mu_{\text{T100}}\)
  • \(H_a: \mu_{\text{T95}} > \mu_{\text{T100}}\)

Applying the Two-Sample T-Test

#Applying the Two-Sample T-Test
t.test(x = df$t95,y = df$t100,var.equal=TRUE, alternative = "greater")
## 
##  Two Sample t-test
## 
## data:  df$t95 and df$t100
## t = 2.6751, df = 14, p-value = 0.009059
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.8608158       Inf
## sample estimates:
## mean of x mean of y 
##  9.366625  6.846625

CONCLUSIONS:

  • The P-values is 0.009059

  • Since the P-Value (0.009059) is less than significance level (0.05), I reject the null hypothesis. This indicates that wafers baked at 95°C have a greater mean photoresist thickness compared to those baked at 100°C

  • The sample average for t95 is 9.367

  • The sample average for t100 is 6.847

  • The T-statistic value is 2.675

4.1.2 Section (b)

(b) What is the P-value for the test conducted in part (a)?
The P-value is 0.009059

4.1.3 Section (c)

(c) Find a 95 percent confidence interval on the difference in means. Provide a practical interpretation of this interval.
The 95% confidence interval (0.860158, Infinity) indicates that the photoresist thickness is at least 0.860158, greater for wafers baked at 95°C compared to those at 100°C

  • \(\mu_{\text{T95}} - \mu_{\text{T100}} \geq 0.8608\)

4.1.4 Section (e)

(e) Check the assumption of normality of the photoresist thickness.
To check the assumption of normality I plot the normal probability plot:

# Plot the normal probability plot
qqnorm(df$t95, main="QQ plot for temp 95")

qqnorm(df$t100, main="QQ plot for temp 100")

CONCLUSIONS: The QQ plot shows some deviations from normality at the tails but aligns closely with a normal distribution for the majority of data points. This suggests that we can be assumed normality

4.1.5 Section (f)

(f) Find the power of this test for detecting an actual difference in means of 2.5 kA.
First I need to calculate the “Effect size”

Effect Size (Cohen’s d):

\[ d = \frac{\mu_1 - \mu_2}{S_p} \]

Where Sp:

\[ S_p = \sqrt{\frac{(n_1-1) \cdot s_1^2 + (n_2-1) \cdot s_2^2}{n_1 + n_2 - 2}} \]

# variance for the two sample T-Test:
Std_temp95 <- var(df$t95)
Std_temp100 <- var(df$t100)

# Sp value:
sp<-sqrt((((8-1)*Std_temp95)+((8-1)*Std_temp100))/(8+8-2))

# d value:
diff_mean = 2.5
d = diff_mean/sp

Applying Power T-Test.

# Applying Power T-Test.
pwr.t.test(n = 8, d = d, sig.level = 0.05, power = NULL, type = "two.sample", alternative = "greater")
## 
##      Two-sample t test power calculation 
## 
##               n = 8
##               d = 1.32694
##       sig.level = 0.05
##           power = 0.8098869
##     alternative = greater
## 
## NOTE: n is number in *each* group

CONCLUSIONS: - Power value = 0.8099 - There is a 81% chance of correctly rejecting the null hypothesis



5 Question 2.32

The diameter of a ball bearing was measured by 12 inspectors, each using two different kinds of calipers. The results were

(a) Is there a significant difference between the means of the population of measurements from which the two samples were selected? Use \(\alpha = 0.05\).
(b) Find the P-value for the test in part (a).
(c) Construct a 95 percent confidence interval on the difference in mean diameter measurements for the two types of calipers.

5.1 Solution - Question 2.32

Creating the Dataframe:

#Creating the Dataframe:
caliper1 <- c(0.265, 0.265, 0.266, 0.267, 0.267, 0.265, 0.267, 0.267, 0.265, 0.268, 0.268, 0.265)
caliper2 <- c(0.264, 0.265, 0.264, 0.266, 0.267, 0.268, 0.264, 0.265, 0.265, 0.267, 0.268, 0.269)
df <- data.frame(caliper1,caliper2)
df
##    caliper1 caliper2
## 1     0.265    0.264
## 2     0.265    0.265
## 3     0.266    0.264
## 4     0.267    0.266
## 5     0.267    0.267
## 6     0.265    0.268
## 7     0.267    0.264
## 8     0.267    0.265
## 9     0.265    0.265
## 10    0.268    0.267
## 11    0.268    0.268
## 12    0.265    0.269

5.1.1 Section (a)

(a) Is there a significant difference between the means of the population of measurements from which the two samples were selected? Use \(\alpha = 0.05\).

The hypothesis to test are:

  • \(H_0: \mu_{\text{caliper1}} = \mu_{\text{caliper2}}\)
  • \(H_a: \mu_{\text{caliper1}} \neq \mu_{\text{caliper2}}\)

Applying Paired T-Test.

# Applying Paired T-Test.
t.test(x = df$caliper1, y = df$caliper2, alternative = "two.sided", conf.level = 0.95, paired = TRUE)
## 
##  Paired t-test
## 
## data:  df$caliper1 and df$caliper2
## t = 0.43179, df = 11, p-value = 0.6742
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -0.001024344  0.001524344
## sample estimates:
## mean difference 
##         0.00025

CONCLUSIONS:

  • The P-values is 0.6742

  • Since the P-Value (0.6742) is greater than significance level (0.05), I fail to reject the null hypothesis. This indicates that there is not difference between the means of the population of measurements from which the two samples were selected

  • The mean difference is 0.00025

  • The T-statistic value is 0.43179

5.1.2 Section (b)

(b) Find the P-value for the test in part (a).
The P-values is 0.6742

5.1.3 Section (c)

(c) Construct a 95 percent confidence interval on the difference in mean diameter measurements for the two types of calipers.
The 95% confidence interval of (-0.001024344, 0.001524344) indicates that the estimated difference in mean diameter measurements is very close to zero and suggests that the differences are minimal.



6 Question 2.34

An article in the Journal of Strain Analysis (vol. 18, no. 2, 1983) compares several procedures for predicting the shear strength for steel plate girders. Data for nine girders in the form of the ratio of predicted to observed load for two of these procedures, the Karlsruhe and Lehigh methods, are as follows:

(a) Is there any evidence to support a claim that there is a difference in mean performance between the two methods? Use \(\alpha = 0.05\).
(b) What is the P-value for the test in part (a)?
(c) Construct a 95 percent confidence interval for the difference in mean predicted to observed load.
(d) Investigate the normality assumption for both samples.
(e) Investigate the normality assumption for the difference in ratios for the two methods.
(f)Discuss the role of the normality assumption in the paired t-test.

6.1 Solution - Question 2.34

Creating the Dataframe:

#Creating the Dataframe:
girder <-c("S1/1","S2/1", "S3/1", "S4/1", "S5/1", "S2/1", "S2/2", "S2/3", "S2/4")
karlsrushe <-c(1.186,1.151,1.322,1.339,1.200,1.402,1.365,1.537,1.559)
lehigh <-c(1.061,0.992,1.063,1.062,1.065,1.178,1.037,1.086,1.052)
df <- data.frame(girder,karlsrushe, lehigh)
df
##   girder karlsrushe lehigh
## 1   S1/1      1.186  1.061
## 2   S2/1      1.151  0.992
## 3   S3/1      1.322  1.063
## 4   S4/1      1.339  1.062
## 5   S5/1      1.200  1.065
## 6   S2/1      1.402  1.178
## 7   S2/2      1.365  1.037
## 8   S2/3      1.537  1.086
## 9   S2/4      1.559  1.052

6.1.1 Section (a)

(a) Is there any evidence to support a claim that there is a difference in mean performance between the two methods? Use \(\alpha = 0.05\).

I considered Paired t-test since the data for the Karlsruhe and Lehigh methods are measured on the same girders

The hypothesis to test are:

  • \(H_0: \mu_{\text{Karlsruhe}} = \mu_{\text{Lehigh}}\)
  • \(H_a: \mu_{\text{Karlsruhe}} \neq \mu_{\text{Lehigh}}\)

Applying Paired T-Test.

# Applying Paired T-Test.
t.test(x = df$karlsrushe, y = df$lehigh, alternative = "two.sided", conf.level = 0.95, paired = TRUE)
## 
##  Paired t-test
## 
## data:  df$karlsrushe and df$lehigh
## t = 6.0819, df = 8, p-value = 0.0002953
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  0.1700423 0.3777355
## sample estimates:
## mean difference 
##       0.2738889

CONCLUSIONS:

  • The P-values is 0.0002953

  • Since the P-Value (0.0002953) is less than significance level (0.05), I reject the null hypothesis. This indicates that there is a difference in mean performance between the two methods.

  • The mean difference is 0.2738889

  • The T-statistic value is 6.0819

6.1.2 Section (b)

(b) What is the P-value for the test in part (a)?
The P-values is 0.0002953

6.1.3 Section (c)

(c) Construct a 95 percent confidence interval for the difference in mean predicted to observed load.
The 95% confidence interval of (0.1700423, 0.3777355) indicates that the estimated difference in mean between the Karlsruhe and Lehigh methods is significant

6.1.4 Section (d)

(d) Investigate the normality assumption for both samples.

Normal probability plot for both samples

# Plot QQ Plot for Karlsrushe Method
qqnorm(df$karlsrushe, main = "Normal probability plot for Karlsrushe Method")

# Plot QQ Plot for Lehigh Method
qqnorm(df$lehigh, main = "Normal probability plot for Lehigh Method")

CONCLUSIONS: - Normal probability plots indicate that both datasets are mostly normally distributed. Although there is a outlier in the Lehigh method, most of the points tend to align forming a straight line

6.1.5 Section (e)

(e) Investigate the normality assumption for the difference in ratios for the two methods.

# Calculate the difference between the two methods
difference <- df$karlsrushe - df$lehigh

# Plot the normal probability plot
qqnorm(difference, main ="Normal probability plot for the difference between two methods")

CONCLUSIONS: - Normal probability plots indicate that is normally distributed since it tend to align forming a straight line

6.1.6 Section (f)

(f)Discuss the role of the normality assumption in the paired t-test.

The assumption of normality is important for the validity of the paired t-test because it ensures that the distribution of the mean (in this case, the difference in means) is well approximated by a t-distribution. This is important because it allows for the confidence interval and the p-values derived from the test to be valid and reliable.

7 Complete R-Code

# Libraries
library(pwr)
library(lawstat)
library(dplyr)

# QUESTION 2.24
# Creating the Dataframe:
machine1<- c(16.03,16.04,16.05,16.05,16.02,16.01,15.96,15.98,16.02,15.99)
machine2 <- c(16.02,15.97,15.96,16.01,15.99,16.03,16.04,16.02,16.01,16.00)
machines <- data.frame(machine1,machine2)
machines

# Checking the variance
var(machines$machine1)
var(machines$machine2)

# Plot a boxplot
boxplot(machines$machine1,machines$machine2)

# Applying the Two-Sample T-Test
t.test(x = machines$machine1,y = machines$machine2, var.equal = FALSE, alternative = "two.sided", onf.level = 0.95)

# QUESTION 2.26
# Creating the Dataframe:
burn_time <- c(65, 81, 57, 66, 82, 82, 67, 59, 75, 70, 64, 71, 83, 59, 65, 56, 69, 74, 82, 79)
type <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
df_burning <- data.frame(burn_time,type)
df_burning$type <- as.factor(df_burning$type)
df_burning

# Using Levene’s Test to test the Hypothesis
levene.test(y = df_burning$burn_time, group = df_burning$type, location = "mean")

# Applying the Two-Sample T-Test
burn_type1 <- df_burning %>% filter(type==1) %>% select(burn_time)
burn_type2 <- df_burning %>% filter(type==2) %>% select(burn_time)
t.test(x = burn_type1,y = burn_type2,var.equal=TRUE, alternative = "two.sided")

# QUESTION 2.27
# Creating the Dataframe:
f_rate125 <- c(2.7,4.6,2.6,3.0,3.2,3.8)
f_rate200 <- c(4.6,3.4,2.9,3.5,4.1,5.1)
df <- data.frame(f_rate125,f_rate200)
df

# Applying the Non Parametric Two sample t-test
wilcox.test(x = df$f_rate125, y=df$f_rate200)


# QUESTION 2.29
#Creating the Dataframe:
t95 <- c(11.176, 7.089, 8.097, 11.739, 11.291, 10.759, 6.467, 8.315)
t100 <- c(5.263, 6.748, 7.461, 7.015, 8.133, 7.418, 3.772, 8.963)
df <- data.frame(t95,t100)
df

# Checking the Variance (using Levene's test)
thickness = c(t95,t100)
temp = c("t95","t95","t95","t95","t95","t95","t95","t95","t100","t100","t100","t100","t100","t100","t100","t100")
df2 <- data.frame(thickness, temp)
levene.test(y = df2$thickness, group = df2$temp, location = "mean")

#Applying the Two-Sample T-Test
t.test(x = df$t95,y = df$t100,var.equal=TRUE, alternative = "greater")

# Plot the normal probability plot
qqnorm(df$t95, main="QQ plot for temp 95")
qqnorm(df$t100, main="QQ plot for temp 100")

# variance for the two sample T-Test:
Std_temp95 <- var(df$t95)
Std_temp100 <- var(df$t100)

# Sp value:
sp<-sqrt((((8-1)*Std_temp95)+((8-1)*Std_temp100))/(8+8-2))

# d value:
diff_mean = 2.5
d = diff_mean/sp

# Applying Power T-Test.
pwr.t.test(n = 8, d = d, sig.level = 0.05, power = NULL, type = "two.sample", alternative = "greater")

# QUESTION 2.32
#Creating the Dataframe:
caliper1 <- c(0.265, 0.265, 0.266, 0.267, 0.267, 0.265, 0.267, 0.267, 0.265, 0.268, 0.268, 0.265)
caliper2 <- c(0.264, 0.265, 0.264, 0.266, 0.267, 0.268, 0.264, 0.265, 0.265, 0.267, 0.268, 0.269)
df <- data.frame(caliper1,caliper2)
df

# Applying Paired T-Test.
t.test(x = df$caliper1, y = df$caliper2, alternative = "two.sided", conf.level = 0.95, paired = TRUE)

# QUESTION 2.34
#Creating the Dataframe:
girder <-c("S1/1","S2/1", "S3/1", "S4/1", "S5/1", "S2/1", "S2/2", "S2/3", "S2/4")
karlsrushe <-c(1.186,1.151,1.322,1.339,1.200,1.402,1.365,1.537,1.559)
lehigh <-c(1.061,0.992,1.063,1.062,1.065,1.178,1.037,1.086,1.052)
df <- data.frame(girder,karlsrushe, lehigh)
df

# Applying Paired T-Test.
t.test(x = df$karlsrushe, y = df$lehigh, alternative = "two.sided", conf.level = 0.95, paired = TRUE)

# Plot QQ Plot for Karlsrushe Method
qqnorm(df$karlsrushe, main = "Normal probability plot for Karlsrushe Method")
# Plot QQ Plot for Lehigh Method
qqnorm(df$lehigh, main = "Normal probability plot for Lehigh Method")

# Calculate the difference between the two methods
difference <- df$karlsrushe - df$lehigh
# Plot the normal probability plot
qqnorm(difference, main ="Normal probability plot for the difference between two methods")