Exercise

# Scatter plot with Regression: the automated approach

Instead of manually including the **regression analysis**, you can also do it in an **automated** way.

To do so, you first have to create a **regression model**. This can be done by the `lm()`

function. To predict `posttest`

from `pretest`

, you can write `lm(posttest ~ pretest, data = mydata100)`

. Since both `posttest`

and `pretest`

are present in `mydata100`

, the data argument is specified as an argument in the `lm()`

function.

To get the intercept and the slope of the regression model and to plot the regression analysis, you use the `coefficients()`

function on the regression model and use it as an argument in the `abline()`

function. For example:

`abline(coefficients(your_model))`

The `mydata100`

dataset and the `posttest`

and `pretest`

continuous variables are pre-loaded in your workspace.

Instructions

**100 XP**

- Make a scatter plot of the
`pretest`

variable (x-axis) against the`posttest`

variable (y-axis). - Include a regression analysis automatically by creating a regression model
`myModel`

and using the coefficients in the`abline()`

function. Predict`posttest`

from`pretest`

.