Correlation
Correlation plays a very important role in quant finance. It not only determines the relation between the financial attributes but also plays a crucial role in predicting the future of financial instruments. Correlation is the measure of linear relationship between the two financial attributes. Now let us try to compute the different types of correlation in R using Sampledata
, which is used in identifying the orders of components of predictive financial models.
Correlation can be computed by the following code. Let's first subset the data and then run the function for getting correlation:
x<-Sampledata[,2:5] rcorr(x, type="pearson")
This generates the following correlation matrix, which shows the measure of linear relationship between the various daily level prices of a stock:
|
|
|
| |
|
1 |
0.962062 |
0.934174 |
0.878553 |
|
0.962062 |
1 |
0.952676 |
0.945434 |
|
0.934174 |
0.952676 |
1 |
0.960428 |
|
0.878553 |
0.945434 ... |