So now let us learn how to run a simple linear regression model in order.
It is very simple.
We just need to write two lines of code and we'll get out as eight.
For this, we are going to use the L.
M function with Stanford linear model.
So we'll assign a new variable, which is let's call it simple model.
So we'll create a variable name, simple model.
And this will get devalue from a limb function, so it is L.M. and within bracket Foster's D dependent
variable, does it?
Debatable.
We want to predict which is host place.
Then Atilla.
And after this, we will write all of these independent variables that we want to run in this linear
model.
So since there's a simple integration and we will take only one variable, we will choose a room known
as the variable that we are going to put an end with to invade.
Room num.
And their days be off.
So commodities are going to be of.
So the first is dependent variable, which is price.
The Stelazine is used to say on the left side of it, it will be dependent variable.
On the right side of it will be the independent variables.
So do numbers, the independent variable we are using her.
And it is Dee Dee of data that we have created earlier, that Senate.
Today is a new variable.
Simple, more nuclear today.
So let us see what is in the symbol morning.
So will write somebody.
And within brackets, right?
Simple-Minded.
So that's why he said you can see the whole result.
This is the dessert that we wanted from us in Berlin, integration.
Here you can see this columnist named Estimate.
This is giving us the values of B, does it all be done?
And any other bits that we will have to intercept?
Is the constant value.
So this is B to zero.
Room them is that it is our variable.
This is beta one for this variable.
Standard at it, as we told you, and the two related.
These are values, a standard errors.
Using this B.W. and the standard revenue we can do to value, if you remember P-value, is BITA minus
zero divided by standard error.
So this is the key value.
Corresponding to P-value, the software has given us the program to value.
P-value is actually telling us whether the variable is significantly impacting the way variable, which
is house price.
So these three stars, these mean you can look at this index here, three star means zero point zero
zero one level, which means that we are ninety nine point nine percent confident that it is significantly
impacting the house price.
So room number is a variable which is significantly impacting and its relationship is this with the.
What does vitamin D, if you increase Ranum value by one unit, are whole sprays will increase by nine
point zero nine units.
Apart from that, we have discussed it as a double standard, it is E!
We're just coming out to six point five, nine seven on 504 degrees of freedom.
It is 504 because we took N minus two degrees of freedom.
And N is free under six.
So this is 504 degrees of freedom.
This values R-squared just coming out.
Two point forty eight.
Which means that nearly forty eight percent of the variance in the values of house price.
Is explained by this simple model.
Or we can increase this R-squared by introducing new variables which will explain the other parts of
the variants which are not explained by this variable alone.
A district R-squared is something we will discuss when we do multinomial division, and this statistic
will also be discussed in the coming lecture's.
So let me summarize it with one simple linear regression model by simple linear regression, I mean
that we had only one variable.
So price is being predicted using only two known variable.
We ran this model using the single lane and we saw the summary of this variable that we created, simple
model.
And in this somebody we get all the information that we wanted.
These are the values of redoes.
These are the property values you're looking at this.
We understand that variable is significantly impacting the house price.
And this is the relationship of this variable, and these are the Odyssey and R-squared values or this
model.
Now, if you want to also applaud the relationship of these two variables, since these are only two
variables and we can have a two dimensional graph to represent it.
Let's first plodder scatterplot of these two variables to plot that will rate plot and within bracket
we will wait D.F. dollar room no comma.
The Abdollah price, this is X variable and then divide a variable.
Let us run this.
You can see in the plot it is scatterplot, each point is represented by these small circles.
And it has a linear kind of relationship.
And what is the predicted lane?
Do right, that will light a bee line and within bracket rule, write simple model.
So this whole plot, that line on the same stuff.
And here's that line that we have predicted after running these Amberly mitigation model, which is
approximately predicting the values of place.
So you can also see the values of Beadle's dealing with down here.
To be the one meant that if they increase the value of rule number one, unit price should increase
by nearly 10 units.
If you look at this here.
If I'm increasing it from five to six, it is increasing from nearly 10 to 20.
So we're just 19 unit also beat.
Zero is the intercept on the Y axis.
So when when X is zero, what is the value of Y?
If I extrapolate this line, you can probably imagine what the other 340 units on x axis, if I meet
it at the zero level of X, it'll probably be coming at nearly minus thirtyfold value of Y axis.
So that's the Y intercept.
So this is all we're done.
Simple linear regression model.