I show how (here) to create a heat map of the intensity of home purchases from 2000 to 2008 in Los Angeles County, CA using a random sample of 5000observations from the county deeds records. I build off of the code created by David Kahle for Hadley Wickham‘s GGPlot2 Case study competition. I use the results of the geocoding procedure that I outline here as the input data.
How to Geocode Addresses Using the Yahoo! PlaceFinder API
This post contains a link (here) to a python program which geocodes a large number of addresses using the Yahoo! PlaceFinder API. This program manages both the use of the API IDs as well as which files have been completed. The code can also be easily parallelized. The code makes use of earlier work I had done in R to accomplish the same task.
Random Effects Decomposition
Motivation
I work through the error components econometric model outlined in Amemiya (1985). I use Hayashi (2000) as a reference text. I work through this example because I use this model in my working paper with Chris Mayer on bubble identification and I would like to work out the details as I didn’t spend much time on these sorts of models in my core econometrics courses.
In my paper with Chris, I develop a method of identifying relative mispricings between city specific markets in the US residential housing market using flows of speculative buyers between cities and assuming that city sizes are exogenous. Previously, analysts suspected that the housing bubble was due to credit supply factors. I use a random effects model to gauge the relative importance of aggregate credit supply factors and cross-city speculator flows in explaining mis-pricing in the housing market in our sample.
Econometric Framework
I characterize the random effects error components estimator outlined in Amemiya (1985, Ch. 6). Consider a balanced panel with panels and observations per panel. I study a regression specification of the following type:
(1)
I can vectorize this specification by stacking each of these equations:
(2)
Assumptions
I make the following assumptions about the shape of the errors:
Assumption: (Error Structure) I assume that:
1) Unbiased-ness: , and
2) White-Noise: , and
3) Homoskedasticity: , and
What are the key take-aways from these assumptions? First, assumption means that there is a constant term in the explanatory variables. Assumption is just the standard white noise assumption. Assumption is the key restriction. This assumption says that the within and between effects are independent across time and panels respectively. The estimator I define below allows me to learn the values of , and .
Estimation
How do I go about estimating these objects? First, I define some notation to make my life a bit easier and stave of carpel tunnel for a few more semesters:
(3)
Also, let be an unit matrix. I name the error covariance matrix , and then characterize it as a linear function of the variance terms of interest:
(4)
I can write out the inverse of the error covariance matix as follows:
(5)
This formulation shows that the sample error covariance matrix will provide unbiased and consistent estimates if both and . In this not, I am not going to worry about what is the most consistent estimator for the parameters. Next, I want to decompose the error covariance matrix into within, between and indiosyncratic components. To do this I need last piece of notation:
(6)
Think about this as an orthogonal decomposition of a unitary error covariance matrix into each of the components: within, between and idiosyncratic. Then, using this term, Amemiya (1971) shows that the following estimators for the parameter vector :
(7)
Recurrence in 1D, 2D and 3D Brownian Motion
Introduction
I show that Brownian motion is recurrent for dimensions and but transient for dimensions . Below, I give the technical definition of a recurrent stochastic process:
Definition: (Recurrent Stochastic Process) Let be a stochastic process. We say that is recurrent if for any and any point we have that:
(1)
In words, this definition says that if the stochastic process starts out at a point , then if we watch the process forever it will return again and again to within some tiny region of an infinite number of times.
Motivating Example
Before I go about proving that Brownian motion is recurrent or transient in different dimensions, I first want to nail down the intuition of what it means for a stochastic process to be recurrent in a more physical sense. To do this, I use the standard real world example for random walks: a drunk leaving a bar.
Example: (A Drunkard’s Flight) Suppose that Arnold is drunk and leaving his local bar. What’s more, Arnold is really inebriated and can only muster enough coordination to move step backwards or step forward each second. Because he is so drunk, he doesn’t have any control which direction he stumbles so you can think about him moving backwards and forwards each second with equal probability . Thus, Arnold’s position relative to the door of the bar is a stochastic process with independent increments. This process is recurrent if Arnold returns to the bar an infinite number of times as we allow him to stumble around all night. Put differently, if Arnold ever has a last drink for the evening and exits the bar for good, then his stumbling process will be transient.
In the context of this toy example, I show that as I allow Arnold to stumble in more and more different directions (backwards vs. forwards, left vs. right, up vs. down, etc…), his probability of returning to the bar decreases. Namely, if Arnold can only move backwards and forwards, then his stumbling will lead him back to his bar an infinite number of times. If he can move backwards and forwards as well as left and right, he will still wander back to the bar an infinite number of times. However, if Arnold either suddenly grows wings (i.e., can move up or down) or happens to be the Terminator (i.e., can time travel to the future or past), at some point his wandering will lead him away from the bar forever.
Outline
First, I state and prove Polya’s Theorem which characterizes whether or not a random walk on a lattice is recurrent in each dimension . Then, I show how to extend this result to continuous time Brownian motion using the Central Limit Theorem. I attack this recurrence result for continuous time Brownian motion via Polya’s Recurrence Theorem because I think the intuition is much clearer along this route. I find the direct proof in continuous time which relies on Dynkin’s lemma a bit obscure; whereas, I have a very good feel for what it means to count paths (i.e., possible random walk trajectories) on a grid.
Polya’s Recurrence Theorem
Below, I formulate and prove Polya’s Recurrence Theorem for dimensions .
Theorem: (Polya Recurrence Theorem) Let be the probability that a random walk on a dimensional lattice ever returns to the origin. Then, we have that while .
Intuition
Before I go any further into the maths, I walk through the physical intuition behind the result. First, imagine the case where drunk Arnold can only move forwards and backwards. In order for Arnold to return to the bar door in steps1, he must take the exact same number of forward and backwards steps. i.e., he has to choose a sequence of steps such that exactly of them are forward. There are choose ways I could do this:
(2)
What’s more, I know that the probability of each of the paths Arnold could take is just divided by the total number of paths :
(3)
Now consider drunk Arnold’s situation in -dimensions. Here, he must take the exact same number of steps forward and backwards as well as the exact same number of steps left and right. Thus, there are choose ways for Arnold to return to the bar:
(4)
What is this sum computing in words? First, suppose that Arnold takes no steps in the left or right directions, then set and the number of paths he could take back to the bar is equal to the number in the -dimensional case. Conversely, if Arnold takes no steps forwards or backwards, set and again you get the -dimensional case. Thus, the number of possible paths Arnold can take back to the bar in -dimensions is strictly larger than in -dimension. However, Arnold can also take paths which mover along both axes. This sum first counts up the number of ways he can make to end up back at his starting point in the left or right directions. Then, it takes the remaining number of steps, and counts the number of ways he can use those steps to return to the starting point in the forwards and backwards direction.
Note that this process doesn’t add that many new returning paths for each new dimension. Every time I add a new dimension, I’m certainly adding fewer than new paths as:
(5)
However, each path only happens with probability now. The probability of realizing each possible path is decreasing at a rate of :
(6)
Thus, the Polya’s Recurrence Theorem stems from the fact that the number of possible paths back to the origin in growing at a rate that in less than the number of all paths; i.e., the wilderness of paths that do not loop back to the origin is increasing faster than the set of paths which do loop back as we add dimensions.
Proof
Below, I prove this result dimension at a time:
Proof: () The probability that Arnold will return to the origin in steps is the number of possible paths times the probability that each of those paths occurs:
(7)
Next, in order to derive an analytical characterization of this probability, I use Stirling’s approximation to handle the factorial terms in the binomial coefficient:
(8)
Using this approximation and simplifying, I find that:
(9)
Thus, if I sum over all possible periods, I get the expected number of times that drunk Arnold will return to the bar for another night cap. I find that this infinite sum diverges:
(10)
Proof: () Next, I follow all of the same steps through for the dimensional case:
(11)
Summing over all possible path lengths yields a divergent series:
(12)
Proof: () The result for is a bit more complicated as there isn’t a nice closed form expression for each of the terms. I start by simplifying as far as I can:
(13)
Next, I apply the Multinomial Theorem and note that this probability is maximized when . Thus, if I substitute in this value, I will have an upper bound on the probability :
(14)
Summing over all possible path lengths leads to a convergent series, so I know that Arnold may have a final drink at some point during the evening:
(15)
Extension to Brownian Motion
Below, I define Brownian motion in dimensions and then show how to extend the results from Polya’s Recurrence Theorem from random walks on a lattice to continuous time Brownian motion.
Brownian motion for dimensions is a natural extension of the dimensional case. I give the formal definition below:
Definition: (Multi-Dimensional Brownian Motion) Brownian motion in is the vector valued process:
(16)
To extend Polya’s Recurrence Theorem to continuous time Brownian motion, I just need to apply the Central Limit Theorem and then construct the Brownian motion from the resulting independent Gaussian increments:
Theorem: (deMoivre-Laplace) Let be the number of successful draws from a binomial distribution in tries. Then, when , we can approximate the binomial distribution with the Gaussian distribution with the approximation becoming exact as :
(17)
Lemma: (Levy’s Selector) Suppose that and and are random variables defined on the same sample space such that has a distribution which is . Then there exists a random variable such that and are independent with a common distribution.
- Sanity Check: Why and not just here? ↩
Hong and Stein (1999)
1. Introduction
I replicate main results from Hong and Stein (1999) which constructs an equilibrium model with under-reaction and momentum. First, I give a rough verbal explanation of the model’s results. Then, I outline the basic mathematical framework and work through the equilibrium concept. Finally, I simulate the equilibrium outcomes for different momentum trader horizons and information speeds.
This paper develops an interesting model in which endogenizes the frequency and amplitude of price fluctuations. I work through this paper to better understand the nuts and bolts of this equilibrium concept. Perhaps I might be able to use these statistical wave-like properties to identify and discriminate between different mis-pricing generators.
2. Simple Example
The basic idea behind the model is as follows. Suppose that you have a bunch of traders that receive a demand shock, but only respond slowly. For example, imagine that a bunch of people earn a windfall payment (i.e. win the lottery or find out about a long lost rich uncle) and decide to buy new houses. It would take them a while to search for the appropriate house that fits their exact needs. For instance, perhaps one family needs to be in a nice school district, another needs to be near the airport for frequent trips, and so on… These guys represent slow moving information or demand. However, though it would take time for each of the people to purchase their new home, and anyone who knew about the windfall payments would know that the demand for expensive houses was going to jump up in the future.
Now, suppose that no one knows that the windfall payments have already occurred; but there is, instead, a group of traders that know a windfall payment might occur at anytime. It could have been today. It could have been yesterday. It might actually happen in a week. Yet, while this group doesn’t know when the payment has been made, each of the agents can infer the likelihood from the price movements. If the price drifts up, then it is more likely that helicopters have dumped the cash. A trader who acts on these price movements is a momentum trader.
There are 2 additional quirks: 1) The informed traders don’t realize that other people have also recieved a windfall payments. 2) Momentum traders enter sequentially and are very simple minded. They don’t know how many of their own kind there are. They don’t meet anyone for lunch to discuss what are the best ways to back out whether or not there has been a windfall payment. All they do is make their best guess based on the price growth over the past 6 months. That’s it.
What happens now? The first couple of momentum traders that walk into the market will see a price jump after the windfall actually occurs and trade into it. However, the next few momentum traders will see the price growth induced by the earlier momentum traders and get very excited and trade into the asset even further. These momentum traders are responding to a price movement that was solely generated by other momentum traders. This pattern repeats itself until the bottom falls out. So, it is as if the later momentum traders pay a tax for being late. Early price movements accelerate, then over shoot their fundamental value and collapse.
3. Economic Framework
First, let’s consider a world with only a unit mass of naive, but informed traders. Agents live in a discrete time period world where is large. There is a riskless asset with a return as well as a risky asset in positive net supply which pays out a dividend at time . The asset has an expected dividend and price at each interim period . These traders all start out with the same information and the same endowment of the riskless asset and risky asset . Each trader has CARA utility over consumption at time :
(1)
The traders are informed because they receive a series of signals about the size of the dividend at each point in time . However, these signals move slowly throughout the population. Specifically, suppose that there are different flavors of traders of equal size. Each flavor of traders sees a different, independent component of the signal at each point in time. So, for example, at time , traders of type see the component of the shock . At time , type traders see the second component of the shock as well as the first component of the shock . Likewise, at time , traders of type see the component of the shock as so on.
Thus, the traders of each flavor rotate which component of the shock they see until they have seen all independent components and know the full shock. This information rotation structure means that, after periods since time , agents have seen a fraction of the total signals available for the shock .
Traders are naive because they do not condition on the observed price when they formulate their expectations. Traders see their components of the shock at each point in time, update their beliefs about the future value of the dividend, and then place their order believing that they will adopt a buy and hold until date strategy, but they do not impound the market clearing price into their information set.
Equilibrium Concept: Walrasian equilibrium with private valuations.
4. No Momentum Traders
To solve the model, I follow the same general strategy as in a Grossman and Stiglitz (1983) equilibrium, but I give the traders naive rather than rational expectations. First, I write out the optimization problem for each naive, informed trader . I assume that and solve a period problem, but the solutions below easily generalize to and multiple periods.
Each trader maximizes his consumption utility by choosing his asset holdings subject to a budget constraint where represents his riskless asset holdings and represents his risky asset holdings:
(2)
I assume that each trader has a unit mass of wealth. After substituting in the budget constraint, I get:
(3)
The first order condition with respect to characterizes the risky holdings as follows:
(4)
Next, I guess that price is linear in the public information, the private signal about tomorrows information and the total quantity. denotes the public signal available to traders of both flavors. denotes the sum of the private signals for each type of trader .
(5)
I solve for by substituting the function for into the budget constraint. Since both flavors of agents are symmetric and ignorant of the information in the prices themselves, the price functional simplifies to:
(6)
is a function of the risk aversion parameter as well as the variance . I pick the risk aversion parameter in order to set for simplicity.
5. With Momentum Traders
Now, I add in momentum traders. In order to do this, I allow the naive, informed traders to believe that the risky asset supply is a random variable. Thus, they remain blissfully unaware that there are momentum traders at all. Momentum traders also have CARA utility but, rather than living until date , these traders have shorter term horizons and die out at date if they enter at date . Momentum traders earn their name because, rather than observing the sequence of dividend shocks like the naive informed traders above, momentum traders update their beliefs solely on past price movements: .
For simplicity, I pick below. I conjecture that moment traders demand is a linear function of past price growth:
(7)
I denote price in the momentum regime as rather than . Informed traders solve the exact same problem as before, since they see the supply shock as a random variable rather than an informative signal. Now, momentum traders affect the quantity available. I can rewrite the pricing equation from above as:
(8)
So that the price today reflects both the current knowledge of all of the naive informed traders as well as the myopic response of the momentum traders where the summation over comes into play since their are generations of momentum traders in the market at any given time. As is standard in models with CARA agents, the momentum traders choose according to the rule below where represents the moment trader’s risk aversion parameter:
(9)
An equilibrium is a price and a quantity demanded by the momentum traders such that both the pricing and mean variance equations above are satisfied. I solve for the equilibrium numerically in R.
6. Code
Click HERE to view the code used to create these plots.
You must be logged in to post a comment.