# Load the tidyverse
# Read in the datasetModule 4 Assignment 2: Applying Regression
Assignment Details
Purpose
The goal of this assignment is to assess your ability to perform and interpret linear regressions and to perform a statistical analysis for your research question.
Task
Write R code which produces the correct answers and correctly interpret the results of visualizations and statistical tests.
Criteria for Success
- Code is within the provided code chunks
- Code chunks run without errors
- Code produces the correct result
- Code that produces the correct answer will receive full credit
- Code attempts with logical direction will receive partial credit
- Written answers address the questions in sufficient detail
Assignment Questions
In this assignment, we are going to continue using the hair grass data set from class.
At the end of the assignment, you will perform the correct statistical analysis for your own research question.
Section 1
Set-Up
As always, we must get organized before we can do anything!
First, load the tidyverse and read in the hair grass data set.
Linear Regression with Hairgrass Data
Take a look at the hairgrass data and choose one of the environmental variables we think might influence hairgrass density that we have not used in class (AKA choose one other than nitrogen content or soil pH).
- Calculate the mean and standard deviation of your chosen environmental variable.
Now, we are going to explore the relationship between your chosen variable and hairgrass densities.
Which variable is the independent variable? Which is the dependent?
Independent:
Dependent:
Create a scatter plot of hair grass density and the environmental variable (do not add a line of best fit yet).
Be sure to make the labels easier to understand and add a theme. Also make sure that the dependent variable is on the y-axis.
Write 1-2 sentences interpreting the plot above. Is this a positive relationship, negative relationship or no relationship at all? Based on your prediction, do you think the correlation coefficient will be positive, negative, or zero?
Answer:
Calculate the correlation coefficient,
r.
- Calculate the
r^2value. Write a one sentence interpretation of what ther^2value means in the context of these two variables. (2 points)
Interpretation:
What are the null and alternative hypotheses regarding the relationship between these two variables?
Null:
Alternative:
Create a scatter plot that includes the line of best fit. Again, make the labels clearer, add a theme, and make sure the correct variables are on the correct axes.
- Run a linear regression model and print out the summary.
Write out the equation for the line of best fit using numeric values from the results above and the variable names.
Answer:
Interpret the model summary. What is the p-value for our variable of interest? Do we reject or fail to reject the null hypothesis regarding the relationship between these two variables? What can we conclude, then, about the relationship between your chosen environmental variable and hair grass density? (2 points)
Answer:
Section 2
Running A Statistical Model for Your Research Question
In this module, we have covered 3 different statistical analyses: t-tests, ANOVAs, and linear regression. It is now time to decide how to apply these statistical analyses to your own research question!
For this part of the assignment, referring back to Module 2 Assignment 3 will be very helpful!
Set-Up: Research Question and Data
First, write your research question below (this really helps us when grading!).
Research question:
Now that you’ve written out your research question above, read in your chosen dataset for your final project.
Conceptual
Take a look back at Module 2, Assignment 3; this is the assignment where you explored your choices for data sets to use for the final assignment. Between questions 2 and 3, there is a lot of very important information about how you should treat certain variables in each dataset.
Assisted by that information, determine whether each variable in your research question is numeric or categorical.
Answer:
- State which variable is dependent and which one is independent.
Answer:
- Based on your answers to Questions 12 and 13 above and other information about your chosen dataset, determine which statistical analysis you should perform to answer your question. In 1-2 sentences, explain how you know.
Answer:
Analysis
- Perform the appropriate statistical analysis below. If necessary, add an additional line of code to print out the results.
- If necessary, run a pairwise comparison. If a pairwise comparison is unnecessary for your statistical analysis, explain why.
Answer:
# space for code to run a pairwise comparison if needed- Interpret the results of your statistical analysis (including the pairwise comparison, if relevant). In your answer, include the p-value and if the result of your analysis is significant. Do you reject or fail to reject your null hypothesis? What do these results mean in the context of your research question? (2 points)
Answer: