So we can do that by basically fitting a formula that's just a,

a line so remember the formula for a line is going to be the

eruption duration here is equal to a constant or an inter, what people call

an intercept term, plus another constant times

the waiting time plus the error term.

So.

As you saw in the previous slide, even if a

line fit through the middle of the data looks like

it's sort of a reasonable approximation to the relationship, there's

obviously not, the points don't exactly fall in a line.

And that's why we allow for some error in our model.

The error models, everything that we didn't have,

we didn't measure, we didn't understand about the relationship.

And so we can use the lm command in r to fill linear model.

So lm, relates the eruptions, that's going to be

the outcome variable that you're trying to predict,

the tilde says we're going to predict it as

a function of everything on this side of the.

The code right here, we're going to use the waiting data.

We're going to build that model using the data from

the training set, so if we do that, if we

do that, we get a summary of the output and

the point, the part to look at, assumes the prediction here.

Are these estimates so the estimate here is just the intercept that's the constant.

So that's B0, in this formula, and the waiting time estimate here is B1 in

this formula, and so if we get a new prediction, we just add minus 1.79.

Plus 0.073 times whatever our new waiting time is

and that produces our new prediction for the expected duration.