Module # 5 assignment
Question #1
a.
Null Hypothesis (H0): The machine is producing cookies according to the manufacturer's specifications, with a mean breaking strength of 70 pounds.
Alternative Hypothesis (Ha): The machine is not producing cookies according to the manufacturer's specifications, with a mean breaking strength different from 70 pounds.
b.
a <- 70
s <- 3.5
n <- 49
xbar <- 69.1
z <- (xbar - a) / (s / sqrt(n))
p_value <- 2 * pnorm(-abs(z))
alpha <- 0.05
if (p_value < alpha) {
cat("Reject the null hypothesis. There is evidence that the machine is not meeting the manufacturer's specifications.\n")
} else {
cat("Fail to reject the null hypothesis. There is no evidence that the machine is not meeting the manufacturer's specifications.\n")
}
c.
The computed p-value is the probability of observing a sample mean as extreme as 69.1 pounds, assuming the null hypothesis is true. If the p-value is less than the significance level (0.05), we reject the null hypothesis. In this case, the p-value is computed as 0.0001438, which is less than 0.05. Therefore, we reject the null hypothesis and conclude that there is evidence that the machine is not meeting the manufacturer's specifications.
d.
s_new <- 1.75
z_new <- (xbar - a) / (s_new / sqrt(n))
p_value_new <- 2 * pnorm(-abs(z_new))
if (p_value_new < alpha) {
cat("Reject the null hypothesis. There is evidence that the machine is not meeting the manufacturer's specifications.\n")
} else {
cat("Fail to reject the null hypothesis. There is no evidence that the machine is not meeting the manufacturer's specifications.\n")
}
e.
xbar_new <- 69
z_new <- (xbar_new - a) / (s / sqrt(n))
p_value_new <- 2 * pnorm(-abs(z_new))
if (p_value_new < alpha) {
cat("Reject the null hypothesis. There is evidence that the machine is not meeting the manufacturer's specifications.\n")
} else {
cat("Fail to reject the null hypothesis. There is no evidence that the machine is not meeting the manufacturer's specifications.\n")
}
Question #2
xbar <- 85
sigma <- 8
n <- 64
alpha <- 0.05
# Calculate the margin of error
margin_of_error <- qnorm(1 - alpha/2) * (sigma / sqrt(n))
# Calculate the confidence interval
lower_limit <- xbar - margin_of_error
upper_limit <- xbar + margin_of_error
cat("95% Confidence Interval for μ: (", lower_limit, ", ", upper_limit, ")\n")
Question #3
a.
# Girls Data
goals_girls <- c(4, 5, 6)
grades_girls <- c(49, 50, 69)
# Boys Data
goals_boys <- c(4, 5, 6)
grades_boys <- c(46.1, 54.2, 67.7)
# Calculate Pearson correlation coefficient for girls
correlation_girls <- cor(goals_girls, grades_girls, method = "pearson")
cat("Pearson correlation coefficient for girls:", correlation_girls, "\n")
b.
# Calculate Pearson correlation coefficient for boys
correlation_boys <- cor(goals_boys, grades_boys, method = "pearson")
cat("Pearson correlation coefficient for boys:", correlation_boys, "\n")
c.
# Create a scatter plot for girls
plot(goals_girls, grades_girls, main = "Girls - Goals vs. Grades", xlab = "Goals", ylab = "Grades", pch = 19)
abline(lm(grades_girls ~ goals_girls), col = "blue") # Add a regression line
text(4, 69, paste("Correlation:", round(correlation_girls, 2)), pos = 4)
# Create a scatter plot for boys
plot(goals_boys, grades_boys, main = "Boys - Goals vs. Grades", xlab = "Goals", ylab = "Grades", pch = 19)
abline(lm(grades_boys ~ goals_boys), col = "red") # Add a regression line
text(4, 67.7, paste("Correlation:", round(correlation_boys, 2)), pos = 4)
Comments
Post a Comment