2.13.1.2 corrcoef(Pro)


Menu Information

Statistics: Descriptive Statistics: Correlation Coefficient

Brief Information

Calculate correlation coefficients for two or more columns

Additional Information

This feature is for OriginPro only.

Command Line Usage

1. corrcoef irng:= (wcol(1), wcol(2), wcol(3)) spearman:=1;
2. corrcoef irng:= (wcol(1):wcol(3)) scatter:=1;
3. corrcoef irng:= (col(a), col(b), col(c)) rt:= [book2]<new name:=CorrCoef> flag:=1;
4. corrcoef irng:= (col(a), col(b)) spearman:=1 kendall:=1 swks:=[<input>]<new> kwks:=[<input>]<new> flag:=1;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input irng

Input

Range

<active>
Specify the input data ranges, at least two ranges.
Pearson pearson

Input

int

1
Decide if Pearson's product moment correlation coefficient is computed.
Spearman spearman

Input

int

0
Decide if Spearman Rank correlation coefficient is computed.
Kendall kendall

Input

int

0
Decide if Kendall correlation coefficient is computed.
Scatter plots scatter

Input

int

0
Indicate whether to produce scatter plots for each pair of ranges.
Add Confidence Ellipse ellipse

Input

int

0
Decide whether the confidence ellipse is plotted.
Confidence Level for Ellipse(%) conflevel

Input

double

95
Specify the confidence level for the confidence ellipses.
Exclude Missing Values missing

Input

int

0
Specify how to exclude the missing values.

Option list:

  • pairwise:Pairwise
    Exclude the missing value pairwisely. That is, when computing correlation between two columns, the corresponding two entries will be excluded if there is any missing value.
  • listwise:Listwise
    Exclude the missing value listwisely. That is, exclude the entire row for all dataset if there are any missing values.
Plot Data rd

Output

ReportData

<optional>
Specify the output worksheet for scatter/ellipse data.
Plots rtplot

Output

ReportTree

<optional>
Specify the report worksheet for scatter plots and confidence ellipse.
Results rt

Output

ReportTree

[<input>]<new>
Specify the output worksheet for analysis results.
Pearson Sheet pwks

Output

Worksheet

[<input>]<new>
Specify the output worksheet for Pearson Correlations.
Spearman Sheet swks

Output

Worksheet

<optional>
Specify the output worksheet for Spearman Correlations.
Kendall Sheet kwks

Output

Worksheet

<optional>
Specify the output worksheet for Kendall Correlations.
Show Significance in Result Table sig

Input

int

1
Specify whether to display Significance in Result Table in the report worksheet.
Flag Significant Correlations flag

Input

int

0
Specify whether to mark the Correlation Coefficient value significant at the 0.05 level with asterisk in Result Table, and highlight the Correlation Coefficient value significant at the 0.05 level with red color in Pearson/Spearman/Kendall Sheet.

Examples

  • Sample Code
/*
This example shows how to caculate three kinds of correlation coefficents, which are Pearson, 
Spearman and Kendall correlation coefficent,When the distributions of the two variables satisfy 
normality, we can use Pearson correlation coefficent to describe the relationship of the two 
variables.Contrariwise, we should use Spearman or Kendall correlation coefficent.
  OriginPath\Samples\Statistics folder.
1. Import the sample data into a book in Origin
2. use corrcoef XF to calculate the correlation coefficents
3. put the result into a new sheet
4. Plot the scatter into a new graph
*/
/*Import the sample data into a new book*/
string fname$=system.path.program$ + "Samples\Statistics\correlations.dat";
newbook;
impASC;
string bkn$=%H;
/*New a sheet to store the results*/
newsheet book:=bkn$ name:="Result" label:="method|coefficent|Sig.";

/*Use the corrcoef XF to calculate the correlation coefficent*/
corrcoef irng:=[bkn$]1!(col(2),col(3)) pearson:=1 rt:=<new name:="Pearson_Result">;
corrcoef irng:=[bkn$]1!(col(2),col(3)) pearson:=0 spearman:=1 rt:=<new name:="Spearman_Result">;
corrcoef irng:=[bkn$]1!(col(2),col(3)) pearson:=0 kendall:=1 rt:=<new name:="Kendall_Result">;
plotxy iy:=[bkn$]1!(2,3) plot:=201 ogl:=<new name:="Scatter Plot">;

//The first column of the new book is used to store the method of the correlation coefficent.
//The second one is exploited to store the coefficent, and the significant value is put in the third column. 
range method=[bkn$]Result!col(1);
range coef=[bkn$]Result!col(2);
range Sig=[bkn$]Result!col(3);
method[1]$=Pearson;
method[2]$=Spearman;
method[3]$=Kendall;
getresults iw:=[bkn$]Pearson_Result tr:=mytreePearson;
getresults iw:=[bkn$]Spearman_Result tr:=mytreeSpearman;
getresults iw:=[bkn$]Kendall_Result tr:=mytreeKendall;
coef[1]=mytreePearson.peasoncorr.corr1.c2;
Sig[1]=mytreePearson.peasoncorr.Sig1.c2;
coef[2]=mytreeSpearman.spearcorr.corr1.c2;
Sig[2]=mytreeSpearman.spearcorr.Sig1.c2;
coef[3]=mytreeKendall.kencorr.corr1.c2;
Sig[3]=mytreeKendall.kencorr.Sig1.c2;

More Information

For more information, please refer to our User Guide.

Related X-Functions

pcorrcoef


Keywords:pearson, spearman, kendall