Answer To: STAT XXXXXXXXXXExtra Credit Homework (24 pts – 4 pts per part) Due Date: 4/20/2020 (Tuesday) ·...
Abr Writing answered on Apr 22 2021
homework.Rmd
---
title: "Video Game Experiment"
subtitle: "Homework"
date: "22/04/2021"
output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = T,
comment = "")
if(!require(ggplot2)) {
install.packages("ggplot2")
library(ggplot2)
}
```
# Part A.
An assumption that we make when using a Latin square design is that the the factors do not interact. If this assumption is violated, the Latin Square design error term will be inflated. Based on the description and design of experiment, it appears that the data approximately satisfies and therefore can be used for fitting the model.
# Part B.
Adding the data into R workspace from the provided Latin Square.
```{r}
performance <- c(
94, 103, 114, 100, 106,
100, 111, 75, 74, 95,
98, 51, 94, 70, 81,
101, 110, 85, 93, 90,
112, 90, 107, 106, 73
)
sound.level <- c(
1, 3, 4, 5, 2,
3, 2, 1, 4, 5,
4, 1, 5, 2, 3,
2, 5, 3, 1, 4,
5, 4, 2, 3, 1
)
time.order <- rep(paste0("order",1:5), 5)
day <- paste0("day", c(
rep(1, 5),
rep(2, 5),
rep(3, 5),
rep(4, 5),
rep(5, 5)
))
latin.square <- data.frame(
day, time.order, sound.level, performance
)
latin.square$day <- as.factor(latin.square$day)
latin.square$day <- as.factor(latin.square$day)
head(latin.square)
```
Plotting the data
```{r}
ggplot(latin.square,
aes(x=day,
y=performance,
color = time.order,
size = sound.level)) +
geom_point() +
theme(axis.text.x = element_text(angle = 30, hjust = 1))
```
From the plot above, we can see that higher sound level until level 4 resulted in higher performance with an exception of day 2. However, there seems to be an interaction between the order and the sound level as on Day 2, the time order 2 seems to have the highest performance.
# Part C.
```{r}
model <- lm(performance ~ day +
time.order +
sound.level +
sound.level*day +
sound.level*time.order,
data = latin.square)
anova(model)
```
From the table above, we can see that the groups based on any interaction is not statistically significant and thereofre satisfying the model assumptions.
```{r}
model <- lm(performance ~ .,
data = latin.square)
anova(model)
```
# Part D.
Look at the significance of the F-test from th results of analysis of variance above, we can have following conclusions:
- The difference between group considering the time order is not significant (p-value > 0.1);
- The difference between group considering the sound level is quite significant (p-value < 0.05);
- The difference between group considering the day is significant (p-value < 0.1);
# Part E.
## Day
```{r}
pairwise.t.test(performance, day)
```
## Sound Level
```{r}
pairwise.t.test(performance, sound.level)
```
## Time...