MATH1324 Assignment 3

Exploring the difference between weights after a specific diet plan

Hewayalage Vishva Lahiru Kantha Abeyrathne (s3735195) Kodithuwakku Arachchige Iresh Udara Kaushalya (s3704769)

Last updated: 28 October, 2018

Introduction

Problem Statement

Problem Statement Cont.

Data

Data Cont.

Descriptive Statistics and Visualisation

#Descriptive Statistics for weight6weeks and pre.weight
Diet %>%summarise(
  Mean_weight6weeks = mean(weight6weeks, na.rm = TRUE),
  SD_weight6weeks= sd(weight6weeks, na.rm = TRUE),
  Mean_pre.weight = mean(pre.weight, na.rm = TRUE),
  SD_pre.weight= sd(pre.weight, na.rm = TRUE),
  Mean_Difference= mean(weight6weeks - pre.weight, na.rm = TRUE),
  SD_Difference = sd(weight6weeks - pre.weight, na.rm = TRUE),
  n = n()
) -> table1

knitr::kable(table1)
Mean_weight6weeks SD_weight6weeks Mean_pre.weight SD_pre.weight Mean_Difference SD_Difference n
68.68077 8.924504 72.52564 8.723344 -3.844872 2.551478 78

Descriptive Statistics and Visualisation Cont.

#Create differences Column (weight_difference)
Diet <- Diet %>% mutate(weight_difference = weight6weeks - pre.weight)

#Descriptive Statistics for Column d
Diet %>% summarise(
  Min = min(weight_difference, na.rm = TRUE),
  Q1 = quantile(weight_difference, probs = .25, na.rm = TRUE),
  Median = median(weight_difference, na.rm = TRUE),
  Q3 = quantile(weight_difference, probs = .75, na.rm = TRUE),
  Max = max(weight_difference, na.rm = TRUE),
  Mean = mean(weight_difference, na.rm = TRUE),
  SD = sd(weight_difference, na.rm = TRUE),
  IQR = IQR(weight_difference, na.rm = TRUE),
  n = n(),
  Missing = sum(is.na(weight_difference))
) -> table2

knitr::kable(table2)
Min Q1 Median Q3 Max Mean SD IQR n Missing
-9.2 -5.55 -3.6 -2 2.1 -3.844872 2.551478 3.55 78 0

Descriptive Statistics and Visualisation Cont2.

#line plot Visualization
matplot(t(data.frame(Diet$weight6weeks, Diet$pre.weight)),
  type = "b",
  pch = 19,
  col = 1,
  lty = 1,
  xlab = "",
  ylab = "Weight",
  xaxt = "n"
  )
axis(1, at = 1:2, labels = c("After 6 weeks", "Before"))

Descriptive Statistics and Visualisation Cont3.

#Outliers
boxplot(Diet$weight_difference)

Descriptive Statistics and Visualisation Cont4.

#Check normalaity of the differences using Q-Q plot
qqPlot(Diet$weight_difference, dist="norm")

## [1] 17 77

Hypothesis Testing

Hypthesis Testing Cont.

#Calculation of the paired sample t-test

t.test(Diet$weight6weeks, Diet$pre.weight,
       paired = TRUE,
       alternative = "two.sided")
## 
##  Paired t-test
## 
## data:  Diet$weight6weeks and Diet$pre.weight
## t = -13.309, df = 77, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -4.420141 -3.269602
## sample estimates:
## mean of the differences 
##               -3.844872

Discussion

References