Covariance
Show older comments
Hi,
quick question: can someone confirm that Matlab doesn't give back correct results for 'cov ? Example is here: http://www.mathworks.ch/help/techdoc/ref/cov.html
I calculated by hand and excel. I think there's something. Need the covariance for the financial toolbox.
Thanks a lot Ben
2 Comments
David Young
on 13 Mar 2012
If you think the example has the wrong result, what do you think the correct result should be, according to your hand calculation and excel?
David Young
on 14 Mar 2012
Thanks for the information (though perhaps better to edit the question than to add an answer). I think Oleg has the explanantion.
Accepted Answer
More Answers (4)
Oleg Komarov
on 14 Mar 2012
You should read the documentation thoroughly:
cov(A,1)
is the population covariance (divides by N), while
cov(A)
is the sample covariance (divides by N-1)
By default, the functions cov, var and std compute the sample statistic.
Sean Lawson
on 13 Mar 2012
0 votes
I used MATLAB cov and don't experience a wrong answer. Maybe you could post your example here if you cannot find anything wrong.
1 Comment
David Young
on 14 Mar 2012
This strikes me as a comment on the question, rather than an answer to it.
Chinmayee L M
on 19 Jul 2021
0 votes
I didn't quite understand the terminology used in the documentation. Could someone clarify?
The documentation reads:
"If A is a matrix whose columns represent random variables and whose rows represent observations, C is the covariance matrix with the corresponding column variances along the diagonal."
If I have 10 time series with 400 samples, how should the matrix be organised before taking covariance?
a. 10 x 400
b. 400 x 10
Thanks
1 Comment
Chinmayee L M
on 19 Jul 2021
Figured it out.
Input to cov function should be a 10 x 400 matrix.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!