0% found this document useful (0 votes)
18 views

HW6 Hypothesis Testing

This document contains the results of statistical analyses conducted on data from Teams Toni and Tina. It includes: 1) Confidence intervals for the mean mincemeat content, variance of mincemeat content, and percentage of pies containing over 0.19 alcohol units for Team Toni. 2) Hypothesis test results comparing the average pie weight, variance of mincemeat content, and percentage of high alcohol pies between Teams Toni and Tina. 3) Four hypothesis tests on additional data: a) whether a sample is representative of a population, b) difference in mean ages between obese and non-obese groups, c) difference in variability of ages between

Uploaded by

writersleed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

HW6 Hypothesis Testing

This document contains the results of statistical analyses conducted on data from Teams Toni and Tina. It includes: 1) Confidence intervals for the mean mincemeat content, variance of mincemeat content, and percentage of pies containing over 0.19 alcohol units for Team Toni. 2) Hypothesis test results comparing the average pie weight, variance of mincemeat content, and percentage of high alcohol pies between Teams Toni and Tina. 3) Four hypothesis tests on additional data: a) whether a sample is representative of a population, b) difference in mean ages between obese and non-obese groups, c) difference in variability of ages between

Uploaded by

writersleed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MAT 501 HOMEWORK 6

2023-12-19

Question One

# Given data for Team Toni


mean_toni <- 24.01
sd_toni <- 0.32
variance_toni <- 0.1
n_toni <- 23
pies_more_than_019_toni <- 9
alpha <- 0.05

# Given data for Team Tina


mean_tina <- 23.95
sd_tina <- 0.51
n_tina <- 29
pies_more_than_019_tina <- 12

# Confidence Intervals

# Mean of Mincemeat Content (Toni)


margin_of_error_mean_toni <- qt(1 - alpha / 2, df = n_toni - 1) * (sd_toni / sqrt(n_toni))
ci_mean_toni <- c(mean_toni - margin_of_error_mean_toni, mean_toni + margin_of_error_mean_toni)

# Variance of Mincemeat Content (Toni)


chi2_critical_values_toni <- qchisq(c(alpha / 2, 1 - alpha / 2), df = n_toni - 1)
ci_variance_toni <- ((n_toni - 1) * variance_toni) / chi2_critical_values_toni

# Percentage Containing More than 0.19 Alcohol Units (Toni)


p_hat_toni <- pies_more_than_019_toni / n_toni
z_critical_toni <- qnorm(1 - alpha / 2)
margin_of_error_proportion_toni <- z_critical_toni * sqrt((p_hat_toni * (1 - p_hat_toni) + z_critical_to
ci_proportion_toni <- c((2 * n_toni * p_hat_toni + z_critical_toniˆ2 - margin_of_error_proportion_toni)
(2 * n_toni * p_hat_toni + z_critical_toniˆ2 + margin_of_error_proportion_toni)

# Hypothesis Testing

# Claim: Average Weight of Pies (Toni vs. Tina)


t_stat <- (mean_toni - mean_tina) / sqrt((sd_toniˆ2 / n_toni) + (sd_tinaˆ2 / n_tina))
p_value_mean_comparison <- pt(t_stat, df = n_toni + n_tina - 2, lower.tail = FALSE)

# Claim: Variance of Mincemeat Content (Toni vs. Tina)


f_stat <- (sd_toniˆ2 / sd_tinaˆ2)
p_value_variance_comparison <- pf(f_stat, df1 = n_toni - 1, df2 = n_tina - 1, lower.tail = TRUE)

1
# Claim: Percentage of Pies with More than 0.19 Alcohol Units (Toni vs. Tina)
p1_hat_tina <- pies_more_than_019_tina / n_tina
z_stat_tina <- (p_hat_toni - p1_hat_tina) / sqrt((p_hat_toni * (1 - p_hat_toni) / n_toni) + (p1_hat_tina
p_value_proportion_comparison <- pnorm(z_stat_tina, lower.tail = FALSE)

# Display results
cat("Confidence Intervals for Team Toni:\n")

## Confidence Intervals for Team Toni:

cat("Mean of Mincemeat Content:", ci_mean_toni, "\n")

## Mean of Mincemeat Content: 23.87162 24.14838

cat("Variance of Mincemeat Content:", ci_variance_toni, "\n")

## Variance of Mincemeat Content: 0.200322 0.05981396

cat("Percentage Containing More than 0.19 Alcohol Units:", ci_proportion_toni, "\n\n")

## Percentage Containing More than 0.19 Alcohol Units: 0.4028326 0.4108884

cat("Hypothesis Testing Results (Toni vs. Tina):\n")

## Hypothesis Testing Results (Toni vs. Tina):

cat("Claim: Average Weight of Pies - p-value:", p_value_mean_comparison, "\n")

## Claim: Average Weight of Pies - p-value: 0.3034017

cat("Claim: Variance of Mincemeat Content - p-value:", p_value_variance_comparison, "\n")

## Claim: Variance of Mincemeat Content - p-value: 0.01402956

cat("Claim: Percentage of Pies with More than 0.19 Alcohol Units - p-value:", p_value_proportion_compari

## Claim: Percentage of Pies with More than 0.19 Alcohol Units - p-value: 0.565278

Question Two

i. Representative Sample

2
# Given data
n <- 500
sample_median <- 53.1
population_median <- 52.3
sample_std_dev <- 11.3

# Test Statistic
t_stat_median <- (sample_median - population_median) / (sample_std_dev / sqrt(n))

# Two-tailed p-value
p_value_median <- 2 * pt(abs(t_stat_median), df = n - 1, lower.tail = FALSE)

# Display result
cat("i. Representative Sample Test Result:\n")

## i. Representative Sample Test Result:

cat("Test Statistic (t):", t_stat_median, "\n")

## Test Statistic (t): 1.583057

cat("p-value:", p_value_median, "\n")

## p-value: 0.114042

ii. Difference in Mean Age

# Given data
n_obese <- 89
mean_age_obese <- 52.6
std_dev_obese <- 13.5

n_non_obese <- 411


mean_age_non_obese <- 48.6
std_dev_non_obese <- 23.5

# Test Statistic
t_stat_mean_diff <- (mean_age_obese - mean_age_non_obese) / sqrt((std_dev_obeseˆ2 / n_obese) + (std_dev_

# Degrees of freedom
df_mean_diff <- (std_dev_obeseˆ2 / n_obese + std_dev_non_obeseˆ2 / n_non_obese)ˆ2 / ((1 / (n_obese - 1))

# Two-tailed p-value
p_value_mean_diff <- 2 * pt(abs(t_stat_mean_diff), df = df_mean_diff, lower.tail = FALSE)

# Display result
cat("ii. Difference in Mean Age Test Result:\n")

## ii. Difference in Mean Age Test Result:

3
cat("Test Statistic (t):", t_stat_mean_diff, "\n")

## Test Statistic (t): 2.172045

cat("p-value:", p_value_mean_diff, "\n")

## p-value: 0.03091665

iii. Difference in Variability

# Test Statistic
f_stat_var_diff <- (std_dev_obeseˆ2 / std_dev_non_obeseˆ2)

# Degrees of freedom
df1_var_diff <- n_obese - 1
df2_var_diff <- n_non_obese - 1

# Two-tailed p-value
p_value_var_diff <- 2 * pf(f_stat_var_diff, df1 = df1_var_diff, df2 = df2_var_diff, lower.tail = FALSE)

# Display result
cat("iii. Difference in Variability Test Result:\n")

## iii. Difference in Variability Test Result:

cat("Test Statistic (F):", f_stat_var_diff, "\n")

## Test Statistic (F): 0.3300136

cat("p-value:", p_value_var_diff, "\n")

## p-value: 2

iv. Difference in Proportions

# Given data
n_support_obese <- 26
n_support_non_obese <- 138

# Proportions
p_support_obese <- n_support_obese / n_obese
p_support_non_obese <- n_support_non_obese / n_non_obese

# Test Statistic
p_hat_pooled <- (n_support_obese + n_support_non_obese) / (n_obese + n_non_obese)

4
z_stat_prop_diff <- (p_support_obese - p_support_non_obese) / sqrt(p_hat_pooled * (1 - p_hat_pooled) * (

# Two-tailed p-value
p_value_prop_diff <- 2 * pnorm(abs(z_stat_prop_diff), lower.tail = FALSE)

# Display result
cat("iv. Difference in Proportions Test Result:\n")

## iv. Difference in Proportions Test Result:

cat("Test Statistic (Z):", z_stat_prop_diff, "\n")

## Test Statistic (Z): -0.7948962

cat("p-value:", p_value_prop_diff, "\n")

## p-value: 0.4266739

You might also like