QR Decomposition via Householder Reflections in VBA

With thanks to Prof Bindel of the Big Red.

I am putting this up because the wikipedia example on this is divinely lacking in what normal people consider “correct”ness or clarity of exposition.

Source - qrdecomp

Working implementation - qrdecomp

It uses a slightly modified version of my Newton v1.10 library – all modifications will be incorporated in the next revision of Newton.

I put in a nifty thing I have been learning about for numerical precision (first time I actually used the concept of a machine epsilon), wrestled with some SUPREMELY annoying bugs in Excel’s inbuilt MMult function (I have had to build my own replacement), and wrote out some little functions we take for granted in Matlab like Eye and Norm (or, for that matter, qr…). I left the code uncleaned for the time being in case there are still minor bugs I haven’t found.

I have a sneaking suspicion that all this work could have been avoided if I could figure out a way to derive the Q and R matrices from the results of OLS regression, as Excel actually does their LINEST function WITH an inbuilt QR algorithm (and OF COURSE they choose NOT to let users access the QR algo). However I couldn’t derive any sort of backward inductive relationship.

Twitter – Week of 2012-04-15

  • You make a man wanna speak Spanish #
  • Walruses = Walrii? #
  • oh yay an xkcd feature! http://t.co/rcf8ZsCy #
  • Ya hi I'd like to suspend, not shut down, my campaign. in case the other guy screws up. Or something. #
  • Tryin to get my Usher on but I can't let it burn #
  • Listen to the rhythm of the falling rain #
  • I think there's a market for high end digital watches. Every high end watch I know emphasizes how anachronistically it measures time. #
  • BofA suing itself 11 times, hilarious http://t.co/NnDGv2Y9 #
  • “A belief is not an idea held by the mind, it is an idea that holds the mind” Elly Roselle #
  • @joseliz no idea dude I'm not even in the US, I suspect only NYC based people get to do it #
  • My game for PhDs involves aWarcraft mod called Thesis Defense where they build ivory towers to shoot down theses. vice versa for candidates #

Powered by Twitter Tools

Paper on Principal Component Equivalent Deltas

I’m proud to present the first paper I have ever done for work – Principal Component Equivalent Deltas. It’s of literally sophomoric complexity, of course, but it helped solve an important portfolio management problem we were handling.

The premise is this: much of the literature on principal component analysis in finance focuses on how well the first three principal components explain price or rate changes, i.e a change in price C at time T can basically be reduced to Ct = a*P1t+b*P2t+c*p3t+e, with P1,2,  and 3 being the transformed principal component time series and a,b,c being the loadings.

However, very few sources then extend this to how the principal component loadings can be used for analyzing delta exposures (PCA is for various uninteresting reasons most relevant to fixed income) in a portfolio. Simply applying the PCA loadings to your portfolio delta vector is going to give you a matrix of deltas to the principal components, which is fairly useless because they cannot be directly observed or traded, and also have had their standard deviations boiled out of them. Thus a change of basis is in order, from orthogonal to non-orthogonal. We change them to tradable dimensions for the purposes of intuitive risk analysis and the ability for immediate hedging.

Twentysomething

I always think the store Forever21 (I remain favorably impressioned by a Businessweek article on the Changs from a year back) holds a mirror up to one of our inner wishes, and what we see in the mirror isn’t pretty.

It’s silly – but understandable – how we (especially the college-aged American “we”) cannot wait til we hit 21, for all the liberations and libations reaching that age bestows.

And then we keep going, and going, and going, the memory of one’s Majorité civile receding, like our hairlines before sandworms digging dour dunes across a once carefree brow. Our attitudes towards our own age exhibit a sort of reverse Doppler effect, centered around the age of 21. This side of that semiprime of our lives, our mental-image of that time shifts to a decidedly reddish tinge – less the crackly brown of nostalgia, more the disconsolate tint of regret and remorse. I could have done more. I could have saved time. If only I had - and on and on. Taken in this light, birthdays are not a cause for celebration so much as consternation.

 

Twitter – Week of 2012-04-08

  • I really doubt I will ever get married. #
  • Hi http://t.co/uy46gN38 #
  • Getting 7 hours of sleep tonight! #
  • I hate when it's raining and I still have to wake up #
  • I get seasick whenever I talk to Indian people and they agree with me while I am talking #

Powered by Twitter Tools