predictfunction. The function will help us to plot the linear regression of ANCOVA and also predict other useful information that aids our interpretation (We’ll see later.) The previous exercise can be found here.
Answers to these exercises are available here. If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page. Please load data-set (download here) required before starting this exercise.
Create a linear ANCOVA model using the function
lm (You learned on the previous exercise.)
predict function to predict a response variable (y) at every explanatory variable (x) based on the model created. (exercise 1)
Create a vector to pull the replicates that are repeated: Density and Season.
Predict the value using the
predict function and create it as a data frame.
predict function to find mean values per season.
Play around with the function to find the mean values per levels density.
Plot the result.
- Become a Top R Programmer Fast with our Individual Coaching Program
- Explore all our (>4000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below