.

#1
Introduction

Linear and Logistic regressions are usually the first algorithms people learn in predictive modeling. Due to their popularity, a lot of analysts even end up thinking that they are the only form of regressions. The ones who are slightly more involved think that they are the most important amongst all forms of regression analysis.

The truth is that there are innumerable forms of regressions, which can be performed. Each form has its own importance and a specific condition where they are best suited to apply. In this article, I have explained the most commonly used 7 forms of regressions in a simple manner. Through this article, I also hope that people develop an idea of the breadth of regressions, instead of just applying linear / logistic regression to every problem they come across and hoping that they would just fit!

A . What is Regression Analysis ?
B. Why do we use Regression Analysis ?
C. What are the types of Regressions ?
-- 1. Linear Regression
-- 2. Logistic Regression
-- 3. Polynomial Regression
-- 4. Stepwise Regression
-- 5. Ridge Regression
-- 6. Lasso Regression
-- 7. ElasticNet Regression
D. How to select the right Regression Model ?

A. What is Regression Analysis ?

Regression analysis is a form of predictive modelling technique which investigates the relationship between a dependent (target) and independent variable (s) (predictor). This technique is used for forecasting, time series modelling and finding the causal effect relationship between the variables. For example, relationship between rash driving and number of road accidents by a driver is best studied through regression.

Regression analysis is an important tool for modelling and analyzing data. Here, we fit a curve / line to the data points, in such a manner that the differences between the distances of data points from the curve or line is minimized. I’ll explain this in more details in coming sections.

Regression_Line.png (2.61 KiB) Viewed 1046 times

B. Why do we use Regression Analysis ?

As mentioned above, regression analysis estimates the relationship between two or more variables. Let’s understand this with an easy example:

Let’s say, you want to estimate growth in sales of a company based on current economic conditions. You have the recent company data which indicates that the growth in sales is around two and a half times the growth in the economy. Using this insight, we can predict future sales of the company based on current & past information.

There are multiple benefits of using regression analysis. They are as follows :

1. It indicates the significant relationships between dependent variable and independent variable.
2. It indicates the strength of impact of multiple independent variables on a dependent variable.

Regression analysis also allows us to compare the effects of variables measured on different scales, such as the effect of price changes and the number of promotional activities. These benefits help market researchers / data analysts / data scientists to eliminate and evaluate the best set of variables to be used for building predictive models.

How many types of Regression techniques do we have ?

There are various kinds of regression techniques available to make predictions. These techniques are mostly driven by three metrics (number of independent variables, type of dependent variables and shape of regression line). We’ll discuss them in detail in the following sections.

Regression_Type.png (72.47 KiB) Viewed 1046 times

For the creative ones, you can even cook up new regressions, if you feel the need to use a combination of the parameters above, which people haven’t used before. But before you start that, let us understand the most commonly used Regressions :

1. Linear Regression

It is one of the most widely known modeling technique. Linear regression is usually among the first few topics which people pick while learning predictive modeling. In this technique, the dependent variable is continuous, independent variable(s) can be continuous or discrete, and nature of regression line is linear.

Linear Regression establishes a relationship between dependent variable (Y) and one or more independent variables (X) using a best fit straight line (also known as regression line).

It is represented by an equation Y=a+b*X + e, where a is intercept, b is slope of the line and e is error term. This equation can be used to predict the value of target variable based on given predictor variable(s).

Linear_Regression1.png (5.6 KiB) Viewed 1046 times

The difference between simple linear regression and multiple linear regression is that, multiple linear regression has (>1) independent variables, whereas simple linear regression has only 1 independent variable. Now, the question is “How do we obtain best fit line ?”.

How to obtain best fit line (Value of a and b) ?

This task can be easily accomplished by Least Square Method. It is the most common method used for fitting a regression line. It calculates the best-fit line for the observed data by minimizing the sum of the squares of the vertical deviations from each data point to the line. Because the deviations are first squared, when added, there is no cancelling out between positive and negative values.

reg_error.gif (3.51 KiB) Viewed 1046 times

We can evaluate the model performance using the metric R-square. To know more details about these metrics, you can read: Model Performance metrics Part 1, Part 2 .

Important Points :
- There must be linear relationship between independent and dependent variables
- Multiple regression suffers from multicollinearity, autocorrelation, heteroskedasticity.
- Linear Regression is very sensitive to Outliers. It can terribly affect the regression line and eventually the forecasted values.
- Multicollinearity can increase the variance of the coefficient estimates and make the estimates very sensitive to minor changes in the model. The result is that the coefficient estimates are unstable
- In case of multiple independent variables, we can go with forward selection, backward elimination and step wise approach for selection of most significant independent variables.

2. Logistic Regression

Logistic regression is used to find the probability of event=Success and event=Failure. We should use logistic regression when the dependent variable is binary (0/ 1, True/ False, Yes/ No) in nature. Here the value of Y ranges from 0 to 1 and it can represented by following equation.
odds= p/ (1-p) = probability of event occurrence / probability of not event occurrence
ln(odds) = ln(p/(1-p))
logit(p) = ln(p/(1-p)) = b0+b1X1+b2X2+b3X3....+bkXk
Above, p is the probability of presence of the characteristic of interest. A question that you should ask here is “why have we used log in the equation?”.

Since we are working here with a binomial distribution (dependent variable), we need to choose a link function which is best suited for this distribution.
And, it is logit function. In the equation above, the parameters are chosen to maximize the likelihood of observing the sample values rather than minimizing the sum of squared errors (like in ordinary regression).

Logistic_Regression.png (19.96 KiB) Viewed 1046 times

Important Points :
- It is widely used for classification problems
- Logistic regression doesn’t require linear relationship between dependent and independent variables. It can handle various types of relationships because it applies a non-linear log transformation to the predicted odds ratio
- To avoid over fitting and under fitting, we should include all significant variables. A good approach to ensure this practice is to use a step wise method to estimate the logistic regression
- It requires large sample sizes because maximum likelihood estimates are less powerful at low sample sizes than ordinary least square
- The independent variables should not be correlated with each other i.e. no multi collinearity. However, we have the options to include interaction effects of categorical variables in the analysis and in the model.
- If the values of dependent variable is ordinal, then it is called as Ordinal logistic regression
- If dependent variable is multi class then it is known as Multinomial Logistic regression

3. Polynomial Regression

A regression equation is a polynomial regression equation if the power of independent variable is more than 1. The equation below represents a polynomial equation :
y=a+b*x^2
In this regression technique, the best fit line is not a straight line. It is rather a curve that fits into the data points.

Polynomial.png (2.47 KiB) Viewed 1046 times

Important Points :
- While there might be a temptation to fit a higher degree polynomial to get lower error, this can result in over-fitting. Always plot the relationships to see the fit and focus on making sure that the curve fits the nature of the problem. Here is an example of how plotting can help :

underfitting-overfitting.png (26.92 KiB) Viewed 1046 times

- Especially look out for curve towards the ends and see whether those shapes and trends make sense. Higher polynomials can end up producing wierd results on extrapolation.

4. Stepwise Regression

This form of regression is used when we deal with multiple independent variables. In this technique, the selection of independent variables is done with the help of an automatic process, which involves no human intervention.

This feat is achieved by observing statistical values like R-square, t-stats and AIC metric to discern significant variables. Stepwise regression basically fits the regression model by adding/dropping co-variates one at a time based on a specified criterion. Some of the most commonly used Stepwise regression methods are listed below :

- Standard stepwise regression does two things. It adds and removes predictors as needed for each step.
- Forward selection starts with most significant predictor in the model and adds variable for each step.
- Backward elimination starts with all predictors in the model and removes the least significant variable for each step.

The aim of this modeling technique is to maximize the prediction power with minimum number of predictor variables. It is one of the method to handle higher dimensionality of data set.

5. Ridge Regression

Ridge Regression is a technique used when the data suffers from multicollinearity ( independent variables are highly correlated). In multicollinearity, even though the least squares estimates (OLS) are unbiased, their variances are large which deviates the observed value far from the true value. By adding a degree of bias to the regression estimates, ridge regression reduces the standard errors.

Above, we saw the equation for linear regression. Remember? It can be represented as :
y=a+ b*x
y=a+b*x+e (error term), [error term is the value needed to correct for a prediction error between the observed and predicted value]

This equation also has an error term. The complete equation becomes :
=> y=a+y= a+ b1x1+ b2x2+....+e, for multiple independent variables.
In a linear equation, prediction errors can be decomposed into two sub components. First is due to the biased and second is due to the variance.
Prediction error can occur due to any one of these two or both components. Here, we’ll discuss about the error caused due to variance.

Ridge regression solves the multicollinearity problem through shrinkage parameter λ (lambda). Look at the equation below.
Ridge2.png (22.82 KiB) Viewed 1046 times
In this equation, we have two components. First one is least square term and other one is lambda of the summation of β2 (beta- square) where β is the coefficient. This is added to least square term in order to shrink the parameter to have a very low variance.

Important Points :
- The assumptions of this regression is same as least squared regression except normality is not to be assumed
- It shrinks the value of coefficients but doesn’t reaches zero, which suggests no feature selection feature
- This is a regularization method and uses l2 regularization >>> Wikipedia

6. Lasso Regression

Similar to Ridge Regression, Lasso (Least Absolute Shrinkage and Selection Operator) also penalizes the absolute size of the regression coefficients. In addition, it is capable of reducing the variability and improving the accuracy of linear regression models. Look at the equation below :

Lasso.png (22.06 KiB) Viewed 1046 times

Lasso regression differs from ridge regression in a way that it uses absolute values in the penalty function, instead of squares. This leads to penalizing (or equivalently constraining the sum of the absolute values of the estimates) values which causes some of the parameter estimates to turn out exactly zero. Larger the penalty applied, further the estimates get shrunk towards absolute zero. This results to variable selection out of given n variables.

Important Points :
- The assumptions of this regression is same as least squared regression except normality is not to be assumed
- It shrinks coefficients to zero (exactly zero), which certainly helps in feature selection
- This is a regularization method and uses l1 regularization >>> Wikipedia
- If group of predictors are highly correlated, lasso picks only one of them and shrinks the others to zero

7. ElasticNet Regression

ElasticNet is hybrid of Lasso and Ridge Regression techniques. It is trained with L1 and L2 prior as regularizer. Elastic-net is useful when there are multiple features which are correlated. Lasso is likely to pick one of these at random, while elastic-net is likely to pick both.

Elastic_Net.png (1.36 KiB) Viewed 1046 times

A practical advantage of trading-off between Lasso and Ridge is that, it allows Elastic-Net to inherit some of Ridge’s stability under rotation.

Important Points :
- It encourages group effect in case of highly correlated variables
- There are no limitations on the number of selected variables
- It can suffer with double shrinkage

Beyond these 7 most commonly used regression techniques, you can also look at other models like Bayesian, Ecological and Robust regression

How to select the right regression model ?

Life is usually simple, when you know only one or two techniques. One of the training institutes I know of tells their students – if the outcome is continuous – apply linear regression. If it is binary – use logistic regression! However, higher the number of options available at our disposal, more difficult it becomes to choose the right one. A similar case happens with regression models.

Within multiple types of regression models, it is important to choose the best suited technique based on type of independent and dependent variables, dimensionality in the data and other essential characteristics of the data. Below are the key factors that you should practice to select the right regression model :

1. Data exploration is an inevitable part of building predictive model. It should be you first step before selecting the right model like identify the relationship and impact of variables
2. To compare the goodness of fit for different models, we can analyse different metrics like statistical significance of parameters, R-square, Adjusted r-square, AIC, BIC and error term. Another one is the Mallow’s Cp criterion. This essentially checks for possible bias in your model, by comparing the model with all possible submodels (or a careful selection of them).
3. Cross-validation is the best way to evaluate models used for prediction. Here you divide your data set into two group (train and validate). A simple mean squared difference between the observed and predicted values give you a measure for the prediction accuracy.
4. If your data set has multiple confounding variables, you should not choose automatic model selection method because you do not want to put these in a model at the same time.
5. It’ll also depend on your objective. It can occur that a less powerful model is easy to implement as compared to a highly statistically significant model.
Regression regularization methods(Lasso, Ridge and ElasticNet) works well in case of high dimensionality and multicollinearity among the variables in the data set.

End Note

By now, I hope you would have got an overview of regression. These regression techniques should be applied considering the conditions of data. One of the best trick to find out which technique to use, is by checking the family of variables i.e. discrete or continuous.

In this article, I discussed about 7 types of Regression and some key facts associated with each technique.
As somebody who’s new in this industry, I’d advise you to learn these techniques and later implement them in your models.

Article by Author SUNIL RAY , AUGUST 14, 2015
( a Business Analytics and Intelligence professional with deep experience in the Indian Insurance industry. I have worked for various multi-national Insurance companies in last 7 years )

Source : “The Elements of Statistical Learning” book's
Always looking the GREAT, never left GOOD Point...

### Re: Regression indicator(s) - cTrader

#2
Linear Regression Channel

Draws channel using Linear Regression of Close prices.
Can optionally display Center of Channel (Mean), Edges (maximum Deviation) and Standard Deviation.
Color and Line thickness are also Customizable.

Similar to the 200-day Moving Average, large institutions often look at long term Linear Regression Channels.

A Linear Regression Channel consists of three part's :

1. Linear Regression Line: A line that best fits all the data points of interest. For more information, see: Linear Regression Line.
2. Upper Channel Line: A line that runs parallel to the Linear Regression Line and is usually one to two standard deviations above the Linear Regression Line.
3. Lower Channel Line: This line runs parallel to the Linear Regression Line and is usually one to two standard deviations below the Linear Regression Line.

The multi-year chart of the S&P 500 exchange traded fund (SPY) shows prices in a steady uptrend and maintaining in a tight one standard deviation Linear Regression Channel :

LinRegChannelES1yr6mo.gif (25.7 KiB) Viewed 1027 times

The upper and lower channel lines contain between themselves either 68% of all prices (if 1 standard deviation is used) or 95% of all prices (if 2 standard deviations are used). When prices break outside of the channels, either :
Buy or Sell opportunities are present. Or the prior trend could be ending.

Linear Regression Channel Possible Buy Signal
When price falls below the lower Channel line, and a trader expects a continuation of the trend, then a trader might consider it as a buy signal.

Linear Regression Channel Possible Sell Signal
An opportunity for selling might occur when prices break above the upper Channel line, but a continuation of the trend is expected by the trader.
Other confirmation signs like prices closing back inside the Linear Regression Channel might be used to initiate potential buy or sell orders.
Also, other technical indicators might be used to confirm.

Trend Reversals
When price closes outside of the Linear Regression Channel for long periods of time, this is often interpreted as an early signal that the past price trend may be breaking and a significant reversal might be near.

Linear Regression Channels are quite useful technical analysis charting tools. In addition to identifying trends and trend direction, the use of standard deviation gives traders ideas as to when prices are becoming overbought or oversold relative to the long term trend.

Linear Regression Line

A Linear Regression Line is a straight line that best fits the prices between a starting price point and an ending price point.
A "best fit" means that a line is constructed where there is the least amount of space between the price points and the actual Linear Regression Line.
The Linear Regression Line is mainly used to determine trend direction. A chart of AT&T (T) stock is given below :

LinRegLineT.gif (18.3 KiB) Viewed 1027 times

Traders usually view the Linear Regression Line as the fair value price for the future, stock, or forex currency pair. When prices deviate above or below, traders may expect prices to go back towards the Linear Regression Line.

As a consequence, when prices are below the Linear Regression Line, this could be viewed by some traders as a good time to buy, and when prices are above the Linear Regression Line, a trader might sell. Of course other technical indicators would be used to confirm these inexact buy and sell signals.

A useful technical analysis charting indicator that uses a Linear Regression Line is the Linear Regression Channel (see: Linear Regression Channel), which gives more objective potential buy and sell signals based on price volatility.
Attachments
Linear Regression Channel.zip
Always looking the GREAT, never left GOOD Point...

### Re: Regression indicator(s) - cTrader

#3
Polynomial Regression Channel (PRC)

The Polynomial Regression Channel (PRC) is an RTX Extension indicator that draws a best fit n-degree Polynomial Regression line through a recent Period of data.

Setup parameters for the indicator include the degree of the Polynomial (1 - 6) and Number of bars to Analyze.
Bands are drawn above and below the Regression line between two user-specified Multiples of Standard deviation. The bands self adjust for volatility.

Parameter :

degree --- value for degree
period ---- value for period
strdDev ----- % valiue's of deviation
strdDev2 --- n valiue's of deviation

And can Changes the All Colors Lines ...

NOTE :
[Period] is defines Range of data on Chart.
[Deviation] is used for Building band.
Attachments
prc.zip
Always looking the GREAT, never left GOOD Point...

### Re: Regression indicator(s) - cTrader

#4
Linear Bands

It's same like traditional Bollinger Bands indicator but it use Linear Regression Forecast instead of MA (Moving Average). So it Lag less than Bollinger bands.

Parameter :

source

- High
- Low
- Open
- Close
- Linear Bands Top
- Linear Bands Bottom
- Linear Bands Main

Periods
SD Multiplier

And can Change the Other Colors for Lines : Top, Bottom & Main
Attachments
Linear Bands.zip
Always looking the GREAT, never left GOOD Point...

### Re: Regression indicator(s) - cTrader

#5
The king, you certainly have a strong nickname, but the archives are all dummy without indicators that you describe, so there are already topics with these indicators
Volente Deo

### Re: Regression indicator(s) - cTrader

#6
Antonio wrote:
Mon Jul 02, 2018 5:44 am
The king, you certainly have a strong nickname, but the archives are all dummy without indicators that you describe, so there are already topics with these indicators
Are you high or do you need glasses You don't see the wood for all the trees.

### Re: Regression indicator(s) - cTrader

#7
Krelian99 wrote:
Mon Jul 02, 2018 3:47 pm
Antonio wrote:
Mon Jul 02, 2018 5:44 am
The king, you certainly have a strong nickname, but the archives are all dummy without indicators that you describe, so there are already topics with these indicators
Are you high or do you need glasses You don't see the wood for all the trees.
Of course I need, with such an interpreter, I'm sorry, got into the wrong branch, I'm used to MT 4 only
Volente Deo

1. ### Similar Topics

1. #### Regression Channel

9 Replies 1813 Views

by Antonio, Mon Aug 28, 2017 6:17 pm in Metatrader Indicators

9 Replies
1813 Views
2. #### RSI indicator(s) - cTrader

7 Replies 852 Views

by Tsar, Tue Mar 13, 2018 10:12 pm in cTrader Indicators

7 Replies
852 Views