RSquare (Function)
The RSquare function calculates the square of the Pearson product moment correlation coefficient, R.
Syntax
RSquare(Indep, Dep, Length)
Returns (Double)
A numeric value containing the square of the Pearson product moment correlation coefficient, R.
Parameters
Name |
Type |
Description |
Indep |
Numeric |
Sets the independent value used in the calculation. |
Dep |
Numeric |
Sets the dependent value used in the calculation. |
Length |
Numeric |
Sets the number of bars to be considered in the calculation. |
Remarks
R-Square (r2) is the coefficient of determination, which measures the proportion of variation that is explained by the independent variable in a regression model. This function takes the value of CoeffR for the specified Length and squares the value. that is, CoeffR(Length) * CoeffR(Length). The RSquared value can be interpreted as the proportion of the variance of Price with respect to the specified period (’Length’).
Example
Assigns to Value1 the R-Square calculation based on 14 bars:
Value1 = RSquare(BarNumber, Close, 14);
Additional Example
If you wanted to identify a bar in which the R-Square had been rising for three consecutive bars, you could use the following syntax:
Value1 = RSquare(BarNumber, Close, 14);
If Value1 > Value1[1] AND Value1[1] > Value1[2] AND Value1[2] > Value1[3] Then Plot1(High, "R_risng");