Okay. We've just done a whole bunch of stuff on linear regression, right? We saw

how we could fit one line to data, and then we saw how we could add more

variables and interpret regression output. But there's a problem with this linear

regression. That is that the world is often non linear, right? So, remember I

talked about John Von Neumann saying the study of non linear function is akin to

the study of non elephants. Because there's just so many more non linear

functions than there are linear functions. So if we look out there at the world, we

might see data, right, that looks like this. Or we might see data. Looks like

that, right? Again, or we might see data that sort of has both those features that

looks like that. So the question is, how can we use those techniques we've done

where we've sort of fit lines the best we can, if the world is sort of messy. So

this very short lecture, I just wanna talk about three ways you can get around this

problem that, that the world may be nonlinear, and we've got techniques that

help us sort of understand linear functions. So here's the first thing we

can do. The first thing we can do is we can just approximate our nonlinear

function with a linear function so we've got this nonlinear function here right,

but we're just gonna do a three linear function to approximate it. So that's the

best possible approximation. And so what we can do is we can say I have a model. So

in this case I may have a model that says this is my functional form, this is what

should happen. So I wanna test and say, well does that model work? Well, that

could be a fairly difficult thing to do. So a short cut would be to say, well

instead of testing whether that model works I'm gonna test whether these three

linear models work. This linear approximation comes close. Here's a way to

think of it. Have you ever been to Greenfield Village in Detroit, which is

near Ann Arbor, they've got a brick wall that's curved, right? That goes just like

this, it's a curvy wall. And it's made out of bricks. And the way it's made out of

bricks is there's all these short little straight bricks. Right but the bricks are

laid in such a way. That they make occur. Well, the same thing can go on here. You

can say, my model says the thing should be really curved, but what I can do is I can

approximate that curve. Through some short lines. Now let's push that further to see

the second way you can do this. Suppose you get a bunch of data and the data, now

you notice when you look at this thing, there seems to be sort of different

patterns and different parts. There seems to be a sloping up. In this region, right,

it's sloping down in this region. What you can do is you can break your data into

different quadrants. So you can say okay, here's the first quarter, second quarter,

third quarter. We're just going to assume that we like break it into four equal

parts. Now what you can do is you can say what I want to do is I want to create a

function that's linear in each segment, right, but explains as much of the data as

possible. So here I might start out and say well look, you know, here there's not

much to explain. It's kind of flat. But now when I get here, the data's down here

so I want to come down, I want to head down in this direction. Now I might think,

hey, let's just come way down here. But the promise may come way down here, how am

I going to deal with all this data. Up in here. So what I'm gonna do is I'm gonna

say, nope, that's not gonna work. So, maybe I'll come down just a little bit.

Right? To try to explain some of this. And now when I get up here, I can start

heading up in this direction. Now when I get here, right over in here, I don't want

to head all the way up into this region because I've got to come back down to deal

with this data. So what I'm gonna do is I'm gonna come up here part way and then

I'm gonna head down this way. Now formally this would be called a spine method. But

what's going on here is you're sort of fitting different quadrants of the data to

different linear functions and you're sort of coming close to explaining some of the

nonlinear [inaudible]. So that's, so two things we can do. The first one is that if

I have a model that gives me a nonlinear function, I can replace it with a sequence

of linear functions, the best possible sequence. And then second, if I've just

got a bunch of data and it looks highly nonlinear, I can break the data into

separate parts. Right? And then what I can do is I can fit linear models to each of

the parts. Now there's a third thing I can do. Include non linear terms. Let me

explain what I mean. Suppose our data looks like this. So it looks like it's

kinda coming off like this squared of X, right? Instead of writing Y equals X plus

MX plus B, I could write Y equals M times the square root of X plus B. So what I'm

doing is replacing X with the square root of X. One way to think of this is I could

be. Right, this is Y=MZ+B, right? So that's a linear model. But I'm just

redefining Z to be the square root of X. So again, I'm back to having a linear

model. In fact, I could let Z be anything I want. I could let Z=X squared. If z

equals x square right and I write Y equals. Mz+B. What that would do is that

would fit something that looks like this, where here's Y and here's X. Where it sort

of goes up like a squared tree. So, another way I can deal with

non-linearity?s is just to include non linear terms, and treat them like they're

linear terms. So we've learned three things. The first is, if my model gives me

a function that is nonlinear, I could say; well let's just replace it with a sequence

of linear functions that are approximated. Second thing I can do is my data looks

like it's nonlinear. What I can do is I can break the data into segments and then

fit linear models within each segment and that'll capture some of the nonlinear

[inaudible]. And then the third I can do is I can just introduce nonlinear terms.

So instead of having x1 and x2, I could have the square root of x or I could have

x squared. I could even have something like the log of x or the sin or the cosine

of x, right? I can do anything I want. I could put any function of x in there in

place of x. X is just like a placeholder for some variable. So, even though we

thought about drawing lines through data, we can actually draw sort of any function

through data. Now there's statistics on this, and knowing how accurate your

coefficients are and that's sorta stuff gets more complicated when we start making

these changes. But you can still do it. And if you take into advanced course in

statistics or [inaudible] you learn some of these techniques. What we're trying to

do here though is just getting an understanding of how the models work, and

what linear models do, and even sort of quote unquote linear models with nonlinear

terms do is they help us understand patterns and data. Help us understand how

much of the variation we can explain and understand what's the sine, and what's the

magnitude, right? To become efficient, these are the variables that we think are

important. Okay, thanks.