Drawing Regression Lines in the Zoom-scatter Chart
A regression line, rendered as a straight line, is used to show the trend of y values with respect to the x values or the trend of x values with respect to the y values. A regression line, therefore, can be used to derive a particular trend from the scattered data points in the chart canvas and predict values accordingly. For example, regression lines can be used to find trends and predict future sales, stock prices, currency exchange rates, productivity gains resulting from a training program, and so on.
There are several methods to calculate and draw regression lines; the zoom-scatter chart, using linear regression, uses the least-squares deviation method (also known as the least absolute deviation method). This method calculates the best-fitting straight-line for the observed data by minimizing the sum of the squares of the vertical deviation of each data point from the line (if a point lies on the fitted line exactly, then its vertical deviation is 0). As the deviation values are first squared and then summed, there are no cancellations between positive and negative values.
A zoom-scatter chart rendered with regression lines is shown below:
Given below is a brief description of the attribute used to show regression lines:
Attribute Name | Description |
---|---|
|
It is used to specify whether a regression line will be shown for the chart. Setting this attribute to |
Modes of Regression
Regression lines can be drawn in one of the following two modes:
-
Y on X: (Default mode) Used when y values are predicted, or a trend of y values is calculated, based on the x values
-
X on Y: Used when x values are predicted, or a trend of x values is calculated, based on the y values
In the zoom-scatter chart shown above, the regression lines are drawn in the Y on X mode.
The same chart with the regression lines drawn using the X on Y mode looks like this:
Given below is a brief description of the attributes used to set the mode and customize regression lines:
Attribute Name | Description |
---|---|
|
It is used to specify the mode in which a regression line will be drawn. Setting this attribute to |
|
It is used to specify the hex code of the color that will be used to draw the regression line. |
|
It is used to specify the thickness of the regression line. |
|
It is used to specify the transparency of the regression line. This attribute takes values between |
The formulae used to draw the regression lines for both the modes are given below:
Y on X: The regression equation of Y on X is the equation of the best fitting straight line in the form y=a+bx, where x is the explanatory variable and y is the dependent variable and b=(n . Σ (x.y) - (Σ x).(Σ y) )/ (n Σx² – (Σx)²).
X on Y: The regression equation of X on Y is the equation of the best fitting straight line in the form x=a+by, where y is the explanatory variable and x is the dependent variable and b=(n . Σ (x.y) - (Σ x).(Σ y) )/ (n Σy² – (Σy)²).