Statistics: Descriptive Statistics: Correlation Coefficient
Calculate correlation coefficients for two or more columns
This feature is for OriginPro only.
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;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input | irng |
Input Range |
|
Specify the input data ranges, at least two ranges. Note that beginning with Origin 2020b, there is a shortened syntax that follows the form [Book]Sheet!(N1:N2), N1 = the beginning column index and N2 being the ending column index in a contiguous range of columns. More complex strings from non-contiguous data of the form [Book]Sheet!([Book]Sheet!N1:N2,[Book]Sheet!N3:N4) are also possible. |
Pearson | pearson |
Input int |
|
Decide if Pearson's product moment correlation coefficient is computed. |
Spearman | spearman |
Input int |
|
Decide if Spearman Rank correlation coefficient is computed. |
Kendall | kendall |
Input int |
|
Decide if Kendall correlation coefficient is computed. |
Scatter plots | scatter |
Input int |
|
Indicate whether to produce scatter plots for each pair of ranges. |
Add Confidence Ellipse | ellipse |
Input int |
|
Decide whether the confidence ellipse is plotted. |
Confidence Level for Ellipse(%) | conflevel |
Input double |
|
Specify the confidence level for the confidence ellipses. |
Heatmap Plot | heatmap |
Input int |
|
Specify to output the heatmap plot.
Option List:
|
Scatter Matrix Plot | scatterMatrix |
Input TreeNode |
|
Specify to output the scatter matrix plot.
Option List:
|
Exclude Missing Values | missing |
Input int |
|
Specify how to exclude the missing values.
Option list:
|
Plot Data | rd |
Output ReportData |
|
Specify the output worksheet for scatter/ellipse data. |
Plots | rtplot |
Output ReportTree |
|
Specify the report worksheet for scatter plots and confidence ellipse. |
Results | rt |
Output ReportTree |
|
Specify the output worksheet for analysis results. |
Pearson Sheet | pwks |
Output Worksheet |
|
Specify the output worksheet for Pearson Correlations. |
Spearman Sheet | swks |
Output Worksheet |
|
Specify the output worksheet for Spearman Correlations. |
Kendall Sheet | kwks |
Output Worksheet |
|
Specify the output worksheet for Kendall Correlations. |
Show Significance in Result Table | sig |
Input int |
|
Specify whether to display Significance in Result Table in the report worksheet. |
Flag Significant Correlations | flag |
Input int |
|
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. |
/* 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;
For more information, please refer to our User Guide.
The scatterMatrix tree specifies all setting options for the corrcoef X-Function.
Syntax: scatterMatrix.Treenode:=<value>
Example: scatterMatrix.ellipse = 1
Treenode | Label | Type | Default | Description |
---|---|---|---|---|
ellipse | Add Confidence Ellipse | Input int | 0 | Specify whether to show the confidence ellipse for the Scatter Matrix plot.
|
conflevel | Confidence Level for Ellipse(%) | Input int | 95 | Specify the confidence level for ellipses. This value must be greater than 0 and less than 100. |
Keywords:pearson, spearman, kendall