Prev: UITree child node expansion
Next: memory usage issue
From: Bruno Luong on 20 Jul 2010 06:53 "Sean Douglas" <seanjdouglas(a)hotmail.com> wrote in message <i22v8j$r32$1(a)fred.mathworks.com>... > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <i22glo$jgb$1(a)fred.mathworks.com>... > > "Sean Douglas" <seanjdouglas(a)hotmail.com> wrote in message <i22d79$9jh$1(a)fred.mathworks.com>... > > > > > hey Bruno, thanks for reply, > > > the goal is to find the hedge ratio of one stock against another. I want to know what beta i should mulptiply by my last x term term to make it someone equivalent to the y term. (this is to know how much of one asset should be bought to be relatively equivalent to another asset. I read in a book that this linear relationship code (without a constant term )is the way to find the hedge ratio. I was not familiar with this method before reading it and i dont fully understand it, but i know a little about the least squares mehtod and think that should tell me the correct beta... so i am just trying to understand how the two methods relate and which method is better and if this book i read is truely correct. > > > > > > Is it possible that the linear relationship code ( without constant term) factors in the price difference of the assets x and y when calculating the beta or hedge ratio, and maybe the least sqares approach with the alpha term included does not factor in the asset price differences( the difference in price between x and Y). I have done the math and i know this particular theory is not 100% right, but maybe it has something to do with it. > > > > > > thanks again > > > > Confusing. I don't know what is "hedge ratio". I rather speak math language because it is clear, and no confusion when the problem is described in that language. > > > > If you want to compute the (least-squares) beta WITHOUT constant term, why not use the A matrix as single column x? > > > > A = x; > > > > In that case, six methods on top of my head: > > > > 1. QR: [q r]=qr(x,0); beta=r\(q'*y) > > > > 2: dumb least-squares: beta = inv(x'*x)*x'*y > > > > 3: Pseudo-inverse: beta = pinv(x)*y > > > > 4: backslash: beta = x\y > > > > 5: direct method: beta: (x'*y)/(x'*x) > > > > 6: another variant: dot(x,y)/norm(x)^2 > > > > solve the same least-squares problem, and will give the same thing (fortunately). > > > > If you want to see how to use QR in more complex least-squares problem, check out my FEX contribution: > > > > http://www.mathworks.com/matlabcentral/fileexchange/25453-pseudo-inverse > > > > Bruno > > > thanks again bruno, > I have a question that i think could help explain things. Out of my two methods that you looked at, do you know how one relates to the other? Say i ran both methods on the same x and y vector. Then I would have one answer with just a beta and another answer with an alpha and a beta. Is there some way i could mathematically get the beta from one method to be equal to the beta from the other method? ...maybe by manipulating the alpha???? You might take a look formula of updating the pseudo-inverse (3th method in my post #4) by adding/removing column. The formula can be found on textbook and often used in statistics. A quick search in FEX shows that Yi Cao has posted a Matlab code http://www.mathworks.de/matlabcentral/fileexchange/18087 Bruno |