Correlation Coefficient block

This block calculates a time-weighted correlation coefficient between two input variables.

Return to Overview of blocks

Correlation Coefficient block

Description

The output of the block is the correlation coefficient (R) between two input variables calculated over the last T seconds. The correlation coefficient is thus calculated over a time window of fixed span (width). The window moves forward as time progresses with the one end anchored to current time.

Correlation analysis attempts to measure the strength of linear relationships between variables by means of a single number called a correlation coefficient R. The measure of linear association between two variables X and Y is estimated by the sample correlation coefficient R, where N is the number of samples in the window and R is calculated as follows:

                                     
  

R will have values that range between –1 and +1. A value of +1 indicates that the two variables have a perfect linear relationship over the time window (perfect positive correlation), e.g. X = constant * Y. A value of 0 indicates that there is no linear dependency between the two variables over the time window. If one of the variables has zero variance over the window, this will also result in the block producing an output correlation coefficient of 0, with good quality. A value of –1 indicates that the two variables have a perfect negative linear relationship over the time window (perfect negative correlation), e.g. X = -constant * Y.

Sometimes R2 is used as a measure of the relationship between two variables in stead of just R. R2 will have values that range between 0 and 1. A value of 0 indicates that there is no correlation between the two variables over the time window. A value of 1 indicates that the two variables are perfectly correlated over the time window, either positively or negatively. The closer the value is to 1 the better the correlation is between the two variables, the closer the value is to 0 the worse the correlation is between the two variables.

It is important to take note that the correlation coefficient is a measure of the linear relation between two variables. Therefore, even if two variables are very well correlated via some nonlinear relationship, e.g. Y = X2, the correlation coefficient may indicate a weak correlation. Also note that outliers can skew the correlation coefficient such that weakly correlated variables may seem to have strong correlation. Also, the correlation coefficient does not adjust for the averages of the two variables over the time window, i.e. it does not first make them zero-average by subtracting their respective averages before calculating the correlation coefficient.

Return to top

Correlation coefficient block

Block Type

Statistical block

Input/Output ports

Both input ports can have only fields of type double. The number of outputs is determined by the configuration.

In order for this block to run, both input ports must be connected to sources that only have fields of type double. The window span must also be larger than 0 seconds.

Functions performed on tags

  • On the values – The output port contains fields that have the correlation coefficient R of the configured input fields.

  • On the timestamp – The output time stamp is always set to the execute time.

  • On the quality – The quality is set based on the quality threshold. The quality level is calculated as the number of seconds that both the signals had good quality over the window. This quality level is expressed as a percentage of the window span. If the quality level is less that the quality threshold, the output quality is set to bad, otherwise it is good.

Return to top

Example

  • Sample period = 60s

  • Window span = 300s

  • Quality threshold = 80%

Time Stamps

Process Variable X

Process Variable Y

Correlation Coefficient R

Correlation Coefficient Quality

02/03/26 12:37 

23 

87 

0 

0 

02/03/26 12:38 

12 

34 

1 

0 

02/03/26 12:39 

44 

23 

0.991665 

0 

02/03/26 12:40 

34 

54 

0.434648 

0 

02/03/26 12:41 

26 

71 

0.341591 

1 

02/03/26 12:42 

62 

8 

-0.298520 

1 

02/03/26 12:43 

17 

29 

-0.620760 

1 

02/03/26 12:44 

45 

34 

-0.621630 

1 

02/03/26 12:45 

78 

67 

-0.599800 

1 

02/03/26 12:46 

18 

83 

0.022588 

1 

02/03/26 12:47 

22 

61 

-0.149010 

1 

02/03/26 12:48 

70 

49 

0.092793 

1 

02/03/26 12:49 

10 

13 

-0.337080 

1 

02/03/26 12:50 

21 

26 

0.242454 

1 

02/03/26 12:51 

39 

31 

0.150758 

1 

 

Example of processing by Correlation Coefficient block

Return to top


Related topics:

  

CSense 2023- Last updated: June 24,2025