Tuesday, January 18, 2011

A Casual Chart Pattern Analysis of the California Real Estate Market

Here is plot of prices from Zillow's database, which looks at Zillow's "Zestimate" for the state of California from 1992 to November 2010 (latest available at time of post.)  Below are plots of the first derivative (daily rate of change of prices) and the second derivative (daily rate of change of the first derivative, potentially interpreted as the acceleration in price.)  Please click on the image to enlarge.


I'm not going to claim that I think I can tell the future based on these data.  But I will make some observations and even draw some conclusions therefrom, which the reader is welcome to agree with, criticize or otherwise comment on.

One aspect of the price chart (top) that jumps out at me is the fact that the free-fall that began sometime in 2006, stopped pretty abruptly in July 2009 and actually bounced.  Having studied technical analysis of price patterns in the past, I would refer to the July 2009 low as "support," or a level at which buyers began to overpower sellers and we see a price bounce. (Note that volume does matter in technical analysis and I just don't have that data here, sorry).  So I see strong, recent support at $330K around July 2009.

It is interesting to note that at the same $330K level as we see strong support in July 2009, we also see an inflection point in the graph around May 2003.  In this case, the second derivative goes negative to positive.  Even though this happened over several months, ultimately the second derivative gets quite positive.  This in my view is the point in time at which the irrational exuberance in home buying really "takes off" -- the point where the chart turns concave UP, like an airplane at take off.  It's the point where the upward trend in housing prices begins to accelerate.  I'm not suggesting that the "housing bubble" began May 2003, but that date, and perhaps price level, does seem to be important given the change in concavity (inflection point).

My crystal ball isn't working today, so I don't know the future of the market.  But as of November 2010, the CA market is clearly back around the $330K support level.  My proposition is that if this support level holds, and we see price change go to zero in Dec/Jan/Feb and then higher prices in the spring, then we can say that the $330K support level has been validated.  In my view, this would be a positive turn of events for homeowners, and a point at which we could see even more buyers come to the table and price increases.  If, on the other hand, we see prices fall significantly below this $330K support before the first derivative gets back to zero again, then our support level has been breached and look out below.

I recognize that there are market fundamentals at work.  This market is very complex, with many "structural" issues, such as high-unemployment, a sluggish economic recovery, shadow inventory, government  intervention, etc., etc.  So this is simply a casual attempt by a non-expert to look at price action and patterns (i.e. technical analysis) to see what the data might tell us.  I welcome your comments.

EDIT: Corrected "first" "second" and "third" derivatives.  Learning to count is fun.

EDIT:
Here's a more zoomed in chart with a better look at the July 2009 support level and the May 2003 inflection point.  Click the chart to enlarge.




Sunday, December 19, 2010

Funny Checkmate

This funny position actually came up in one of my 3/0 games online.  I wasn't trying to be funny, it was just the way it came out due to time pressure.  (In playchess.com, if you move before your opponent has moved, the move takes zero time.)

Wednesday, December 1, 2010

Interesting Chess Problem

This position came up in one of my 5 minute online games.  The game may not be all that interesting, but I think this position is.  I did not find the right continuation in the game, and I admit that it was Fritz 10 who found it later.  Can't remember if I won or lost the game.  The position is not as simple as it looks.  White to move and win:

Tuesday, November 30, 2010

Estimating Pi Using the Monte Carlo Method in MATLAB

These MATLAB functions use a large set of uniformly distributed pseudorandom ordered pairs to estimate the area of a circle and then uses the relationship A=πr2 to make an estimate of Pi.  The more random points used (i.e. the larger nsamples), the better the estimate of Pi, as shown in this plot of Pi estimate vs. sample size.  (Click to enlarge, if you're so inclined.  Notice the faint red line at y = π.)

There are two ideas I used for the MATLAB code, one using vectors and the other using only scalar variables.  The vector version seems to perform faster for large nsamples values.  More on that later if I feel like wasting more time!

Here is the code for the scalar only version:
function [MonteCarloPi] = PiEstimate(nsamples)
radius = 0.5;
radiussquared = radius^2;
inside = 0;
for i = 1:nsamples
    x = rand(1)-radius;
    y = rand(1)-radius;
    if x^2 + y^2 <= radiussquared,
        in = 1;            
    else
        in = 0;
    end
    inside = inside + in;
end
areaCircle = inside/nsamples;
MonteCarloPi = areaCircle/radiussquared

And here is the code for the vector version:
function [MonteCarloPi] = PiEstimateVector(nsamples)
radius = 0.5;
radiussquared = radius^2;
areaVector = zeros(nsamples,1);
x = rand(nsamples,1)-radius;
y = rand(nsamples,1)-radius;
rsquared = x.^2 + y.^2;
for i = 1:nsamples
    if rsquared(i) <= radiussquared,
        areaVector(i) = 1;
    end
end
areaCircle = sum(areaVector)/nsamples;
MonteCarloPi = areaCircle/radiussquared

And, finally, a video of the random points filling into the plane on the x and y intervals [-1,-1] with an inscribed circle of unit diameter.  The blue points fall inside the circle, while the red points fall outside the circle.  (Better take a seat before you watch this video.)