Module #8 Assignment

1. Report on drug and stress level by using R. Provide a full summary report on the result of ANOVA testing and what does it mean. More specifically, report using the following R functions: Df, Sum, Sq Mean, Sq, F value, Pr(>F)

I created a data frame with the function:

> data <- data.frame(
+   ReactionTime = c(10, 9, 8, 9, 10, 8, 8, 10, 6, 7, 8, 8, 4, 6, 6, 4, 2, 2),
+   StressLevel = factor(rep(c("High Stress", "Moderate Stress", "Low Stress"), each = 6))

I then printed out the summary of the report using:

> report <- aov(ReactionTime ~ StressLevel, data = data)
> summary(report)

Df Sum Sq Mean Sq F value   Pr(>F)    
StressLevel  2  82.11   41.06   21.36 4.08e-05 ***
Residuals   15  28.83    1.92                     
---
Signif. codes:  
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

From the p-value it can be concluded that there are differences in reaction times between the stress levels.

2.1 The zelazo data (taken from textbook's R package called ISwR) are in the form of a list of vectors, one for each of the four groups. Convert the data to a form suitable for the user of lm, and calculate the relevant test. Consider t tests comparing selected subgroups or obtained by combing groups.   

In order to make the data suitable for a lm report I modified $ctr.8w since it did not match the number of observations of the other variables. I came up with: 

> zelazo_df <- data.frame(
+   Active = zelazo$active[1:5],
+   Passive = zelazo$passive[1:5],
+   None = zelazo$none[1:5],
+   Ctr8w = zelazo$ctr.8w
+ )
> lm_report <- lm(Ctr8w ~ Active + Passive + None, data = zelazo_df)
> summary(lm_report)

> t.test(zelazo_df)

2.1  Consider ANOVA test (one way or two-way) to this dataset (zelazo)
I called aov for each variable. 
> aov(Active ~ 1, data = zelazo_df)
Call:
   aov(formula = Active ~ 1, data = zelazo_df)

Terms:
                Residuals
Sum of Squares         10
Deg. of Freedom         4

Residual standard error: 1.581139

Comments

Popular posts from this blog

Module #11 Assignment

Module #12 Assignment

Module #9 Assignment