Fsgs
Fsgs
Linear Regression
No Relationship
Positive Relationship
Negative Relationship
When to apply Linear Regression
When correlation
coefficient shows that data is
likely to be able to predict
future outcomes
lm() function
The model determines the value of the coefficients
using the input data.
Next we can predict the value of the response
variable for a given set of predictor variables using
these coefficients.
This function creates the relationship model between
the predictor and the response variable.
Syntax
lm(y ~ x1+x2+x3...,data)
y is the response variable.
x1, x2, ...xn are the predictor variables.
Data= dataset
Objective
Dataset : mtcars
GOAL of the model: To establish the relationship
between "mpg" as a response variable with
"disp","hp" and "wt" as predictor variables.
We create a subset of these variables from the mtcars
data set for this purpose.
data(mtcars)
input <- mtcars[,c("mpg","disp","hp","wt")]
print(head(input))
model <- lm(mpg~disp+hp+wt, data = input)
print(model)
summary(model)
1. Create Equation for Regression Model