`predict`

function. 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.

**Exercise 1**

Create a linear ANCOVA model using the function `lm`

(You learned on the previous exercise.)

**Exercise 2**

Use the `predict`

function to predict a response variable (y) at every explanatory variable (x) based on the model created. (exercise 1)

**Exercise 3**

Create a vector to pull the replicates that are repeated: Density and Season.

**Exercise 4**

Predict the value using the `predict`

function and create it as a data frame.

**Exercise 5**

Use the `predict`

function to find mean values per season.

**Exercise 6**

Play around with the function to find the mean values per levels density.

**Exercise 7**

Plot the result.

**What's next:**

- 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

## Leave a Reply