In: Computer Science
Please provide your summary on Linear Regression preferably with some code sample in R.
Hi,
Suppose there are two variables X and Y a linear regression is used to represent how these variables are related or simply linear regression explains the relationship between the two variables.In a linear regression ,in the two variables one is dependent variable and the other is independent variable.Let us consider the eqution of linear regression goven below:
Y=a+bX
Here the variable Y is dependent variable and the variable X is independent variable.Y is called as dependent variable because it depend on the variable X.Whenever X changes the Y also changes.Here Y is also called as the response variable and X is also called as the predictor variable.a and b are constants.Here Y is a mathematical function of X and Y is obtained only if the value of X is known.
In R lm() function is used for linear regression.lm() means linear model.The syntax used to find lm() is :
lm[response variable] = lm([response variable]~[predictor variable],data=[data source]) and we use the command below to review the results:
summary(lm[response variable]) .
Let us consider an example we can find the weight of person if the height is known.There is a relationship between the height and weight of every person.So using linear regression in R we can do it as follows:
lmweight = lm(weight~height,data = height and weight) # here the linear regression is created
summary(lmweight) # the result is reviewed.
In this way linear regression is performed in R.
Thank you....