Module 8 Assignment


Amanda Hidalgo 

10/14/23

LIS 4273: Advanced Stats & Analytics 


Module 8 Assignment 

 

1. Analysis of Variance (ANOVA) for Drug and Stress Level:


```R

# Create a data frame with the given data

data <- data.frame(

  High_Stress = c(10, 9, 8, 9, 10, 8),

  Moderate_Stress = c(8, 10, 6, 7, 8, 8),

  Low_Stress = c(4, 6, 6, 4, 2, 2)

)


# Perform a one-way ANOVA

result <- aov(data ~ stress_level)


# Summary of the ANOVA result

summary(result)

```

This R code performs a one-way ANOVA to test the effects of different stress levels on drug reactions. The output of the ANOVA test will provide you with the degrees of freedom (Df), sum of squares (Sum Sq), mean squares (Mean Sq), F-value, and the p-value (Pr(>F)). You can use these values to interpret the results.


2. Analysis of Zelazo Dataset with ANOVA:


```R

# Load the ISwR package and the zelazo dataset

install.packages("ISwR")

library(ISwR)

data("zelazo")


# Convert the data to a suitable format for ANOVA

active <- zelazo$active

passive <- zelazo$passive

none <- zelazo$none

ctr.8w <- zelazo$ctr.8w


# Combine the data into a single data frame

combined_data <- data.frame(

  group = rep(c("active", "passive", "none", "ctr.8w"), each = 6),

  value = c(active, passive, none, ctr.8w)

)

# Perform a one-way ANOVA

result <- aov(value ~ group, data = combined_data)


# Summary of the ANOVA result

summary(result)

```

This R code loads the ISwR package, accesses the zelazo dataset, and then performs a one-way ANOVA on the data. The ANOVA result will give you information about the differences between the four groups (active, passive, none, ctr.8w) in the zelazo dataset. 

Comments