Question

in general i know that i can easily calculate correlation matrix in matlab,there is a lot of function for this,but what about weighted correlation?i found this matlab file

http://www.mathworks.com/matlabcentral/fileexchange/20846-weighted-correlation-matrix/content/weightedcorrs.m

but how does choosing weights depend on persons intuition or it is standard?

let say we have

x = randn(30,4)

x =

    0.5377    0.8884   -1.0891   -1.1480
    1.8339   -1.1471    0.0326    0.1049
   -2.2588   -1.0689    0.5525    0.7223
    0.8622   -0.8095    1.1006    2.5855
    0.3188   -2.9443    1.5442   -0.6669
   -1.3077    1.4384    0.0859    0.1873
   -0.4336    0.3252   -1.4916   -0.0825
    0.3426   -0.7549   -0.7423   -1.9330
    3.5784    1.3703   -1.0616   -0.4390
    2.7694   -1.7115    2.3505   -1.7947
   -1.3499   -0.1022   -0.6156    0.8404
    3.0349   -0.2414    0.7481   -0.8880
    0.7254    0.3192   -0.1924    0.1001
   -0.0631    0.3129    0.8886   -0.5445
    0.7147   -0.8649   -0.7648    0.3035
   -0.2050   -0.0301   -1.4023   -0.6003
   -0.1241   -0.1649   -1.4224    0.4900
    1.4897    0.6277    0.4882    0.7394
    1.4090    1.0933   -0.1774    1.7119
    1.4172    1.1093   -0.1961   -0.1941
    0.6715   -0.8637    1.4193   -2.1384
   -1.2075    0.0774    0.2916   -0.8396
    0.7172   -1.2141    0.1978    1.3546
    1.6302   -1.1135    1.5877   -1.0722
    0.4889   -0.0068   -0.8045    0.9610
    1.0347    1.5326    0.6966    0.1240
    0.7269   -0.7697    0.8351    1.4367
   -0.3034    0.3714   -0.2437   -1.9609
    0.2939   -0.2256    0.2157   -0.1977
   -0.7873    1.1174   -1.1658   -1.2078

and we have done

x(:,4) = sum(x,2); % Introduce correlation. [r,p] = corrcoef(x) % Compute sample correlation and p-values.

and got

r =

    1.0000   -0.0352    0.2673    0.6901
   -0.0352    1.0000   -0.5101    0.2617
    0.2673   -0.5101    1.0000    0.3504
    0.6901    0.2617    0.3504    1.0000

it is unweighted correlation,but how can i do weighted correlation with help of matlab file?please help me

Was it helpful?

Solution

This function needs the weights of each observation as input. How you choose them is upto you.

If these were outputs of a simulation for example, you could let the weights be the number of performed iterations. If they were stock results, consider using the value in the portfolio. However, there is no standard way to get the 'best' weights in general. Just consider that a value that is more reliable should typically get more weight.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top