

In the output, residual standard error is cost which is 1.525. Values of coefficients(θs) are -87.51667 and 3.45000, hence prediction equation for model is as below Residual standard error: 1.525 on 13 degrees of freedom

Lm(formula = weight ~ height, data = women) Output of the summary function gives information about the object fit. In R, basic function for fitting linear model is lm(). We will discuss about how linear regression works in R. R has powerful and comprehensive features for fitting regression models. R is language and environment for statistical computing. Therefor, we have to minimize cost to meet more accurate prediction. Cost function is denoted by J(θ) and defined as below.Īs we can see from the above formula, if cost is large then, predicted value is far from the real value and if cost is small then, predicted value is nearer to real value. Cost function is used as measurement factor of linear regression model and it calculates average squared error for m observations.

If we take the values of all θ are zeros, then our predicted value will be zero. The goal is to find some values of θ(known as coefficients), so we can minimize the difference between real and predicted values of dependent variable(y). Suppose we have only one independent variable(x), then our hypothesis is defined as below. Here regression function is known as hypothesis which is defined as below. In the Linear regression, dependent variable(Y) is the linear combination of the independent variables(X). There are many techniques for regression analysis, but here we will consider linear regression. In the regression model Y is function of (X,θ). Regression model involves following variables. In the regression, dependent variable is estimated as function of independent variables which is called regression function. The “independent variables” represent the inputs or causes, or are tested to see if they are the cause. Regression analysis helps to understand how the value of the dependent variable changes when any one of the independent variables is varied, while the other independent variables are kept unchanged. The “dependent variable” represents the output or effect, or is tested to see if it is the effect. Focus of regression is on the relationship between dependent and one or more independent variables. Through this post I am going to explain How Linear Regression works? Let us start with what is regression and how it works? Regression is widely used for prediction and forecasting in field of machine learning.
