PRACTICAL5
PRACTICAL5
THEORY:
➢ Regression analysis is a very widely used statistical tool to establish a relationship model
between two variables.
➢ One of these variable is called predictor variable whose value is gathered through
experiments.
➢ The other variable is called response variable whose value is derived from the predictor
variable.
________________________________________________________________________________
1) Linear Regression
o In Linear Regression these two variables are related through an equation, where exponent
(power) of both these variables is 1. Mathematically a linear relationship represents a
straight line when plotted as a graph. A non-linear relationship where the exponent of any
variable is not equal to 1 creates a curve.
i. Carry out the experiment of gathering a sample of observed values of height and
corresponding weight.
ii. Create a relationship model using the lm() functions in R.
iii. Find the coefficients from the model created and create the mathematical equation
using these
iv. Get a summary of the relationship model to know the average error in prediction.
Also called residuals.
v. To predict the weight of new persons, use the predict() function in R.
o Im() Function
i. This function creates the relationship model between the predictor and the
response variable.
ii. Syntax-The basic syntax for lm() function in linear regression is −
lm(formula,data)
2) predict() Function
o Syntax
The basic syntax for predict() in linear regression is − predict(object, newdata)
3) Multiple Regression
o We create the regression model using the lm() function in R. 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.
o lm() Function - This function creates the relationship model between the predictor and the
response variable.
o Syntax
The basic syntax for lm() function in multiple regression is − lm(y ~ x1+x2+x3...,data)
CONCLUSION :
Hence successfully implemented Linear regression, Multiple regression, and Prediction in R
Programming