Module #8 Assignment
Your assignment:
A researcher is interested in the effects of drug against stress reaction. She gives a reaction time test to three different groups of subjects: one group that is under a great deal of stress, one group under a moderate amount of stress, and a third group that is under almost no stress. The subjects of the study were instructed to take the drug test during their next stress episode and to report their stress on a scale of 1 to 10 (10 being most pain).
High Stress | Moderate Stress | Low Stress |
10 | 8 | 4 |
9 | 10 | 6 |
8 | 6 | 6 |
9 | 7 | 4 |
10 | 8 | 2 |
8 | 8 | 2 |
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)
Breakdown of Code:
Stress_Scores combines all of the stress scores into one vector. The score that will be combined are High_Stress, Moderate_Stress, and Low_Stress. This allows us to analyze all the scores rather individually.
The next step is creating a factor for the stress levels. Stress_Levels showcase which stress level each score belongs to. This needs to be repeated six times because there are six observations for each level.
A data frame needs to be created. This data frame combines stress scores and stress levels into a single data frame. The data frame will be titled anova_df.
Using the ANOVA function, aov(), this shows a statistical difference be tween the means of the stress scoress across the different stress levels.
Using summary(stress_anova) the results are shown.
Summary report of ANOVA testing:
ANOVA or Analysis of Variance is used to compare across multiple groups. ANOVA will be used to compare High_Stress, Moderate_Stress, and Low_Stress.
The first step is to create a data frame that includes the stress groups. Once the data frame is created, we uses the ANOVA function. The ANOVA function provides values such as Df, Sum Sq, Mean Sq, F value, and Pr(>F).
Df (Degrees of Freedom):
Stress_Levels: Df represents degrees of freedom. This is the number of independent values that can vary in the analysis. With the Anova test, the degrees of freedom for the factor Stress_Levels is 2 (number of groups - 1).
Residuals: The residual degrees of freedom is 15 (total number of observations - number of groups).
Sum Sq (Sum of Squares):
Stress_Levels: Sum Sq or Sum of Squares, is the total variance explained by each factor. This means the amount of the individual values are varied around their respective mean. The variation between the means of the stress levels is 82.11. A higher number of Stress_Levels indicates more variation between the groups.
Residuals: The variation within the groups is 28.83.
Mean Sq (Mean Square):
Stress_Levels: Mean Sq is the Mean of Squares. This is the sum of squares divided by the respective degree of freedom. This gives an average amount of variation for each value. The sum of squares for Stress_Levels divided by its degrees of freedom equals 41.06.
Residuals: The residual sum of squares divided by its degrees of freedom equals 1.92.
F value:
Stress_Levels: The F value is the ratio of the mean square of the factor to the mean square of the residuals. The larger the F value, this means that the group means are different from one another. The F value is 21.36 indicating significant differences.
Pr(>F):
Pr(>F) or the p-value is what determines if the F is significant. If the p-value is less than the significance level which is usually 0.05, the null hypothesis would be rejected. This means there is a significant difference between the group means. The p-value is 0.000041, which is smaller than 0.05. This means there is differences between the stress levels are significant.
Conclusion of results:
The ANOVA results shows that there is a statistical difference in stress scores across the High, Moderate, and Low stress groups. This indicates that stress levels have a major effect on reaction time scores.
The more stress = more effect on reaction time
----------------------------------------------------------------------------------------------------------------------------
2. From our Textbook: Introductory Statistics with R. Chapter 7. 7.6 Exercises #7.1 pp. 143.
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.
2.1 Consider ANOVA test (one way or two-way) for this dataset (zelazo)
The goal is to see if there is a significant difference in the reaction time across these four groups.
reaction_time: This combines all the values from the four groups into one column.
Groups: This creates a column where each reaction time is lalbled according to the group it belongs to such as active, passive, none, and ctr.8w.
data.frame(): This function combines these two columns into a single data frame.
aov(reaction_time ~ groups): This performs ANOVA where reaction_time is the dependent variable and groups is the independent variable.
summary(zelazo_anova): This prints the ANOVA table.
Summary report of ANOVA testing:
Df (Degrees of Freedom):
Group: This is the number of groups minus 1. There are four groups total so the degrees of freedom for the group is 3.
Residuals: This is the degrees of freedom associated within group variability. This is done by the total number of observations minus the number of groups resulting in 19 degrees of freedom.
Sum Sq (Sum of Squares):
Group: This is the sum of the squared differences between the group means and the overall mean. This reflects the variability between the groups.
Residuals: This is the sum of the squared differences between individual observations and their group means. This reflects the variability within the groups.
Mean Sq (Mean Square):
Group: This is calculated by dividing the sum of squares by the corresponding degrees of freedom.
Group: 14.78 / 3 = 4.926
Residuals: 43.69 / 19 = 2.299
F value:
The F value is the ratio of the mean square of the group to the mean square of the residuals.
F = 4.926 / 2.299 = 2.142
A higher F value showcases greater variance between the groups relative to the variance within the groups.
Pr(>F):
This is the probability of obtaining an F value as large or larger than 0.05.
The p-value is 0.129 which is greater than 0.05
Since the p-value (0.129) is greater than 0.05, we fail to reject the null hypothesis. This indicates there is no statistical significant difference in the mean reaction times across the four groups.
From the results of the ANOVA test, the training methods (active, passive, none, or ctr.8w) does not have a statistically significant effect on the reaction times of the infants.
Now we will be performing a t-test on active and ctr.8w vectors.
t-test on passive and ctr.8w vectors
t-test on active and none vectors
Conclusion of t-tests
Active and ctr.8w vectors: The p-value is less than 0.05. This indicates a statistically significant difference between Active and ctr.8w groups.
Passive and ctr.8w vectors: The p-value is greater than 0.05 meaning there is no significant difference between passive and ctr.8w groups.
Active and none vectors: The p-value is greater than 0.05 meaning there is no significant difference between active and none groups.
Most comparisons did not show significant differences in the means of the group except for active vs. ctr.8w. This indicates that the infants in the active group had a noticeable difference in their response to the ctr.8w group while others groups did not show as significant differences.
Summary:
This week’s assignment focused on analyzing data related to stress reactions using statistical methods, particularly ANOVA and t-tests. I began by exploring the relationship between stress levels and reaction times using ANOVA to determine whether there were significant differences across the groups. Then using the Zelazo dataset from the "ISwR" package, I performed similar analyses to compare walking times across four groups of infants (active, passive, none, ctr.8w). I also became more familiar with concepts such as F-values, p-values, and degrees of freedom. This week's assignment allowed me to get more understanding of real world data in order to compare values to draw conclusions.
Comments
Post a Comment