07 January 2014

R, How to Write It, and Some Bad Quant

The stream of R books continues. Amazon sent this one along this morning. This is the chapter 10 Title:
Loops, The Un-R Way to Iterate

A step in the right direction. Which brings us to a couple of posts that popped up on R-bloggers, also this morning.

"R as a second language".
In most languages if one wants to do something many times the obvious way is using a loop (coded like, for() or while()). It is possible to use a for() loop in R but many times is the wrong tool for the job
There are some complications with some of the design decisions in R, especially when we get down to consistency which begets memorability. A glaring example is the apply family of functions and here is where master opportunist (in the positive sense of expert at finding good opportunities) Hadley Wickham made sense out of confusion in his package plyr.

Both statements ring true: the apply() functions are set-oriented (fits the RDBMS mind-set), and their lineage makes the syntax a Google-able construct which in turn makes the plyr package so much better.

Hot on that post's heels is this one, with a similar point to make.
... in R it is much simpler to take advantage of the R idioms to get there a lot faster. With this approach there is no need for loops or conditional branches. There is also no need for iterative array construction. Instead everything is done in one shot using a set-theoretic approach combined with function transformations.

Again, we read about set. While I've always been irritated by the fanboi need to cloak R in OOD/OOP/functional mystique (rather than actual syntax/semantics/structure), the (nearly) declarative approach to syntax (and, thence semantics) is comforting. R is just FORTRAN's function/data, and folks should just let it go at that. Iteration belongs on the metal, modulo true array processors (which don't explicitly need it); the continuing bottom of the brain stem memory of assembler (and, face it, C) likely accounts for loops in so-called higher level languages. Bah.

So, now we're on to concerns of quants. It seems that Big Data is Dead?
Google Trends shows searches of the term "Big Data" peaked in October, ending a nearly ceaseless climb that began three years earlier.

Huge flatfiles of un-normalized bytes may finally be seen as The Emperor's New Clothes by The Deciders out there:
In the case of Big Data, this probably means less focus on back-end technologies like new types of storage or database frameworks, and a rethinking about how best to integrate human knowledge, algorithms and diverse sets of data.

Can you say: "I want my PL/R"? And have I mentioned: the free-as-in-beer DB2/LUW can accommodate 15 terabytes? You don't get all the really cool bells and whistles, but that's pretty big data.

And now, for a little night music. Jenny Lind was the "Swedish Nightingale", which is close enough to a canary for government work. "We have our canary!" cried some. I'd noticed that house prices had been on a run, but not enough to put fingers to keyboard. This writer is from the AEI, so he blames The Damn Gummint, of course:
Both this bubble and the last one were caused by the government's housing policies, which made it possible for many people to purchase homes with very little or no money down.

Which, of course, is baloney. The bubble was motivated, widely known by anyone not hanging out with Mussolini's ghost, by the financial sector seeking high (but risk free) returns. So, they invented 'interesting' mortgages in order to sell more houses/mortgages which could be packaged together to make high yielding, but low risk (housing is always safe, isn't it?), securities. It wasn't the $10/hour bus drivers who went to CountryWide and said, "make me a mortgage that looks like this". Not the way it happened. The author is clearly confused, because he says:
In 1997, housing prices began to diverge substantially from rental costs. Between 1997 and 2002, the average compound rate of growth in housing prices was 6 percent, exceeding the average compound growth rate in rentals of 3.34 percent. This, incidentally, contradicts the widely held idea that the last housing bubble was caused by the Federal Reserve's monetary policy. Between 1997 and 2000, the Fed raised interest rates, and they stayed relatively high until almost 2002 with no apparent effect on the bubble, which continued to maintain an average compound growth rate of 6 percent until 2007, when it collapsed.

But, later on:
They claim that people will not be able to buy homes. What they really mean is that people won't be able to buy expensive homes. When down payments were 10 to 20 percent before 1992, the homeownership rate was a steady 64 percent -- slightly below where it is today -- and the housing market was not frothy. People simply bought less expensive homes.

Ya can't have it both ways, Jake. The moolah, whether Chinese, German, or American, flooded the mortgage process, pushing up housing costs, while the Banksters went about making mortgages for this housing stock available to the larger number of buyers needed to "clear the market" (cute econ speak, what?). Affordability was swindled in order to conjure the securities. In the short term (and we're definitely in the short term with the Bubble/Recession), only so many units could be built, yet to accommodate the Giant Pool's valuation (Banksters chasing mortgages with ever more bulging pockets) prices had to rise to "clear" the Pool's value. The builders were the ultimate winners:
When anyone suggests that down payments should be raised to the once traditional 10 or 20 percent, the outcry in Congress and from brokers and homebuilders is deafening.

Couldn't agree more; said it before.

I disagree with the use of rental payments as the measure of bubbles, however. There's no material difference between rent and (full load) mortgage; just go read up on what's going on in the Oil Plains States to see the effect of localized inflation of housing. The measure that matters is (local, for some definition of local) median income. No, what drove the Bubble/Recession was the flood of moolah. Without that flood, no amount of fiddling with mortgage lending rules would make a difference; there'd be no reason to generate ever more mortgages made possible by fiddling the rules, since there'd be no increased demand for the resulting securities; no demand means no supply, Laffer be damned. One could argue, even, that had the chronology happened the other way (relaxation of rules, first), no flood of money would have been conjured, since such mortgages would be clearly wonky to those who *need convincing* to part with more moolah, which they either didn't have at all or would have to move from other instruments. It was at the behest of the Giant Pool that the mortgages were conjured. Causation makes a difference, both in assessing blame and determining regulation from here.

In the end, it wasn't The Gummint which drove the The Great Recession. Without the flood of moolah seeking better than Fed rates (so, I guess the author should be pointing the j'accuse finger at Greenspan?), the housing bubble couldn't have happened. Without the quants figuring out how to abuse copulas, it wouldn't have happened. Without the collapse of demand for technical brains in technical professions (thus being 'freed up' to pursue finance, in the sense of automation 'freeing' farmers to work in Detroit after the turn of the 20th century), it wouldn't have happened. Without the decline in median income, and thus the willingness to spend unearned (and unexpected, largely) equity on consumption, it wouldn't have happened.

The author's most egregious lie:
By 1994, Fannie was accepting down payments of 3 percent and, by 2000, mortgages with zero-down payments. Although these lenient standards were intended to help low-income and minority borrowers, they couldn't be confined to those buyers. Even buyers who could afford down payments of 10 to 20 percent were attracted to mortgages with 3 percent or zero down. By 2006, the National Association of Realtors reported that 45 percent of first-time buyers put down no money. The leverage in that case is infinite.

Yet, he contradicts himself with regard to the driving enemy:
In effect, then, borrowing was constrained only by appraisals, which were ratcheted upward by the exclusive use of comparables in setting housing values.

And who drove the appraisals? I guess it must have been The Gummint? For what it's worth: Fairfax County Virginia was using stat analysis of home sales (as opposed to on-site inspection) to do appraisals by, at least, the mid-1970s (I was there). Such software is a big seller, and has been for a long time. Here's one example:
Based on a 20-year proven relational data model and common value approaches (Cost, Market, Comparable Sales and Income), the CAMA module produces reliable and accurate results which also apply if or when an assessment must be defended through the appeal process. Comprehensive comp sheets, ratio analysis and a CAMA valuation sheet that lists all items on a property and the dollar results of each component help automate the document management process.

For the finance types, infinity is (sorta, kinda) accurate. But not for a bus driver earning $10/hour facing an ARM reset. Not even close. The mortgagee is just a homeowner, not a titan of Wall Street. There's no 'real return' to be earned by the homeowner; the homeowner doesn't use the house to build either more or better (or both) 'psychic return' home widgets which he then sells to the market (a la Herbalife). Doesn't work that way. A house isn't an assembly line, or one robot, or even a simple milling machine; it generates no real return to anyone, not even the finance guys (they only get moolah). Leverage is just a red herring.

So, clearly there's more moolah flowing (not, yet, flooding) to the mortgage market. Recent stories have shown that hedge funds (at least) have gotten into the landlord business, buying up large tracts all to once. A more cogent analysis (assuming there's sufficiently granular data) would measure separately for owner-occupied and investor-owned units. It's pretty obvious that median income measures (which are still stagnant, at best) don't support increasing prices. I'd bet on deep pockets looking to monopolize SMAs fighting amongst themselves. Lots of money to be made being the major/sole source of shelter in an SMA.

No comments: