- Function forecasting::SimpleLinearRegression(xIndepVarValue, yDepVarValue, LRcoeff, VariationComp, yEstimates, eResiduals)
forecasting::SimpleLinearRegression
The simple linear regression procedure computes the regression line coefficients based on the values of the observations for the independent and the dependent variables. If desired, the values for variation components and the residuals can be returned as well.
Mathematical Formulation
Using the notation for observations and estimates given in Simple Linear Regression Notation, the estimates of the coefficients of the linear regression line are determined as follows:
These values provide the minimum in \(\hat{\beta}_0\), \(\hat{\beta}_1\) of the function
Therefore, the values \(\hat{\beta}_0\) and \(\hat{\beta}_1\) given above are called the least squares estimates of \(\beta_0\) and \(\beta_1\). With these coefficients, the regression line (1) is called the least squares regression line. Every least squares regression line has the following two properties:
It passes through the point \((\bar{x},\bar{y})\)
\(\sum_{i=1}^{N} e_i = 0\)
Function Prototype
In order to provide the variation components and residuals only when
needed, there are three flavors of the SimpleLinearRegression
procedure provided:
forecasting::SimpleLinearRegression( ! Provides the estimates of the line coefficients, but not the variation components nor the residuals
xIndepVarValue, ! Input, parameter for independent
yDepVarValue, ! Input, parameter for dependent
LRcoeff) ! Output, parameter for line coefficients
forecasting::SimpleLinearRegressionVC( ! Provides the estimates of the line coefficients and the variation components
xIndepVarValue, ! Input, parameter for independent
yDepVarValue, ! Input, parameter for dependent
LRcoeff, ! Output, parameter for line coefficients
VariationComp) ! Output, parameter variation components
forecasting::SimpleLinearRegressionVCR( ! Provides the estimates of the line coefficients, the variation components and the residuals
xIndepVarValue, ! Input, parameter for independent
yDepVarValue, ! Input, parameter for dependent
LRcoeff, ! Output, parameter for line coefficients
VariationComp, ! Output, parameter variation components
yEstimates, ! Output, parameter for estimates
eResiduals) ! Output, parameter for residuals
Arguments
- xIndepVarValue
A one dimensional parameter containing the observations for the independent variable
- yDepVarValue
A one dimensional parameter containing the observations for the dependent variable
- LRcoeff
A one dimensional parameter for storing the coefficients of the regression line
- VariationComp
A one dimensional parameter for storing the values of the variation components
- yEstimates
A one dimensional parameter for storing the values of the estimates
- eResiduals
A one dimensional parameter for storing the values of the residuals
Note
In order to use this function, the Forecasting
system library needs
to be added to the application.
Example
To further understand about this procedure and library, please use the Demand Forecasting example.