Next Page Contents

stats::BPCorr -- Bravais-Pearson correlation

Introduction

stats::BPCorr(data) returns the Bravais-Pearson correlation coefficient of data pairs.

Call(s)

stats::BPCorr([x1, x2, ..], [y1, y2, ..])
stats::BPCorr([[x1, y1], [x2, y2], ..])
stats::BPCorr(s <, cx, cy>)
stats::BPCorr(s <, [cx, cy]>)

Parameters

x1, x2, .. - statistical data: arithmetical expressions.
y1, y2, .. - statistical data: arithmetical expressions.
s - a sample of domain type stats::sample.
cx, cy - integers representing column indices of the sample s. Column cx provides the data x1, x2, .., column cy provides the data y1, y2, ...

Returns

an arithmetical expression. FAIL is returned, if the Bravais-Pearson correlation coefficient does not exist.

Related Functions

stats::FCorr, stats::sample

Details

Example 1

We calculate the Bravais-Pearson correlation coefficient of four pairs of values given in two lists. There is a positive linear relation y = 1+2*x between the entries of the lists:

>> stats::BPCorr([0, 1, 2, 3], [1, 3, 5, 7])
   
                                     1
      

Alternatively, the data may be specified by a list of pairs:

>> stats::BPCorr([[0, 0], [1, -3], [2, -4], [3, -3]])
                                     1/2
                                    5
                                  - ----
                                     3
>> float(%)
                               -0.7453559925

Example 2

We create a sample consisting of one string column and two non-string columns:

>> stats::sample([["a", 0, 0], ["b", 10, 10], ["c", 20, 35]])
   
                               "a"   0   0
                               "b"  10  10
                               "c"  20  35
      

The Bravais-Pearson correlation coefficient is calculated using the data columns 2 and 3. In this example there are only two non-string columns, so the column indices do not have to be specified:

>> float(stats::BPCorr(%))
   
                               0.9707253434
      

Example 3

We create a sample consisting of three data columns:

>> stats::sample([[1, 0, 0], [2, 10, 10], [3, 20, 35]])
                                1   0   0
                                2  10  10
                                3  20  35
      

We compute the Bravais-Pearson correlation coefficient of the data pairs given by the first and the second column:

>> stats::BPCorr(%, 1, 2)
   
                                     1
      

This result indicates that there is a linear relation between these columns. Indeed, the i-th entry y of column 2 is given by y = 10*(x -1), where x is the i-th entry of column 1.

Example 4

We create a sample of three columns containing symbolic data:

>> stats::sample([[1, a, 10], [2, 10, A], [3, 6, 30], [x, 30, 10]])
   
                                1   a  10
                                2  10   A
                                3   6  30
                                x  30  10
      

We compute the Bravais-Pearson correlation coefficient of the data pairs given by the second and the third column. Here we specify these columns by a list of column indices:

>> stats::BPCorr(%, [2, 3])
   
      /                 / A        \ / a        \       \
      | 10 A + 10 a - 4 | - + 25/2 | | - + 23/2 | + 480 | /
      \                 \ 4        / \ 4        /       /
      
         / /  2     / a        \2        \
         | | a  - 4 | - + 23/2 |  + 1036 |
         \ \        \ 4        /         /
      
         /  2     / A        \2        \ \
         | A  - 4 | - + 25/2 |  + 1100 | |^(1/2)
         \        \ 4        /         / /
      

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000