How do I obtain a variance-covariance matrix?

조회 수: 4 (최근 30일)
Calum Crichton
Calum Crichton 2016년 1월 26일
댓글: jgg 2016년 1월 27일
I am trying to maintain the variance-covariance matrix of a 10 asset portfolio of stocks. The data is represented by a column of returns for 10 stocks. I.e.
Stock A Stock B
Return 1 Return 1
Return 2 Return 2
Etc Etc
When I upload my data I have tried the cov(data) function but it will not work. I keep receiving this message:
"Undefined function 'sum' for input arguments of type 'dataset'.
Error in cov (line 154) xc = bsxfun(@minus,x,sum(x,1)/m); % Remove meanUndefined function 'sum' for input arguments of type 'dataset'.
Error in cov (line 154) xc = bsxfun(@minus,x,sum(x,1)/m); % Remove mean"
My question is how do I proceed with finding the average returns of each stock and the variance-covariance matrix?
  댓글 수: 3
Calum Crichton
Calum Crichton 2016년 1월 26일
The imported file is an excel, xlsx, spreadsheet. Label names are only in the first row of every column, which Matlab recognises by default. So I'm unsure why I can't obtain the information I want
jgg
jgg 2016년 1월 27일
No, what is the data type of the information you've loaded in. It looks like you're passing the entire dataset object, instead of just the data, but I can't tell without seeing your code.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by