From f55562e41f3b7df514c34372121a7cbdbe1c7a7b Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Thu, 18 Sep 2025 12:14:39 -0300 Subject: [PATCH] Add A1 --- .gitignore | 8 ++++++ A1.Rmd | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ STAT6473.Rproj | 13 ++++++++++ 3 files changed, 88 insertions(+) create mode 100644 .gitignore create mode 100644 A1.Rmd create mode 100644 STAT6473.Rproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a596fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata + +# Generated Documents +*.html +*.pdf diff --git a/A1.Rmd b/A1.Rmd new file mode 100644 index 0000000..217114b --- /dev/null +++ b/A1.Rmd @@ -0,0 +1,67 @@ +--- +title: "Assignment 1" +subtitle: "STAT3373" +author: "Isaac Shoebottom" +date: "Sept 18th, 2025" +output: + pdf_document: default + html_document: + df_print: paged +--- + +# Question 1 + +## a) + +```{r} +data <- c(14.2, 16.1, 15.8, 17.2, 14.5, 15.3, 16.8, 15.9, 14.7, 16.4, 15.1, 17.5, 15.6, 16.2, 14.9, 15.7, 16.9, 15.4, 16.6, 15.2) +``` + +$$ H_0 : \mu = 15, \space H_\alpha : \mu \neq 15 $$ $$ n = 20, \space \alpha = 0.05, \space \bar{x}=15.8$$ + +```{r} +(mean(data) - 15)/(sd(data)/sqrt(20)) # t-value +qt(1 - (0.05/2), 20-1) # critical t-value + +``` + +Because t is greater than the critical t, 3.910959 \> 2.093024, we can reject the null hypothesis. The medicine does not take effect in 15 minutes + +## b) + +```{r} +qt(1 - (0.05/2), 20-1) * (sd(data)/sqrt(20)) # Interval from mean +mean(data) - qt(1 - (0.05/2), 20-1) * (sd(data)/sqrt(20)) +mean(data) + qt(1 - (0.05/2), 20-1) * (sd(data)/sqrt(20)) +``` + +The confidence interval with 95% confidence is [15.37186, 16.22814] + +# Question 2 + +## a) + +```{r} +before <- c(72, 68, 75, 81, 69, 73, 77, 70, 74, 79) +after <- c(78, 71, 80, 85, 76, 75, 82, 76, 79, 84) +diff <- after - before +``` + +$$ H_0 : \mu \leq 0, \space H_\alpha : \mu > 0$$ $$ n = 10, \space \alpha = 0.01, \space \bar{d}=4.8$$ + +```{r} +mean(diff)/(sd(diff)/sqrt(10)) # t-value +qt(1 - (0.01/2), 10 - 1) # critical t-value +``` + +Because t is greater than critical t, 10.28571 \> 3.249836, we can reject the null hypothesis. The method does improve test scores + +## b) + +```{r} +qt(1 - (0.01/2), 10-1) * (sd(diff)/sqrt(10)) # Interval from mean +mean(diff) - qt(1 - (0.01/2), 10-1) * (sd(diff)/sqrt(10)) +mean(diff) + qt(1 - (0.01/2), 10-1) * (sd(diff)/sqrt(10)) +``` + +The confidence interval with 99% confidence is [3.28341, 6.31659] diff --git a/STAT6473.Rproj b/STAT6473.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/STAT6473.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX