How to create a Beta matrix?
3 views (last 30 days)
Show older comments
Hi all, I’m looking for some help with creating a beta matrix (i.e. the slope function in MS Excel). I’ve imported an nxm Matrix of historical asset prices with n being the number of historical observations and m the number of assets. To create a correlation matrix, I used the following: correlation_matrix = corr(HistPrices); I wondered if a similar function existed for a beta matrix? Or if someone could help me create a script to achieve this. Any help would be greatly appreciated!
1 Comment
dpb
on 2 Feb 2018
Since this is Matlab forum, not unusual that we don't know what a "beta matrix" is in Excel parlance...tell us what you're actually trying to compute. If it is just the slope of a LS regression line for an array of X,Y values, there are a number of ways depending on which Toolboxen you've got installed.
The base ML product polyfit isn't vectorized, but it's trivial to use it in an anonymous function with array/cellfun or just in a for...end loop.
Problem is, we don't know if that's what you're looking for or not...when I hear "beta" and see financial data, I think of the volatility beta.
Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!