Job Search I - Function Inputs


#1

Hi all,

I am reading through the lecture on the McCall search model and I had a question regrading compute_reservation_wage_direct function’s inputs. I understand the ‘params’, ‘max_iter’ and ‘tol’ inputs but the ‘v_iv = collect(.)’ input is unclear to me. I am very new to programming to this might be something trivial but I was unable to find an explanation in the actual lecture.

My experience with functions in Julia is that after I have created a function, I specify the inputs (so far I’ve only had parameters as inputs) and the function returns a value. So I don’t understand why I need the ‘v_iv = collect(.)’ input. If I have understood correctly, the ‘collect’ function creates an array but I am confused as to why this is needed.

I apologise if this is all very trivial.


#2

Hi @Gensys,

First, let’s consider what the v_iv object does. We use it only once, when we use it to create the v vector that we iterate on. In other words, v_iv is something like a seed, or an initial value, that we need for the algorithm.

Now let’s see how it’s implemented.

My experience with functions in Julia is that after I have created a function, I specify the inputs (so far I’ve only had parameters as inputs) and the function returns a value.

This is actually what’s happening here. What we’ve said is that v_iv has a default value (a vector of w/(1-b) for each w), but we can deviate from that if we’d like, by calling the function with compute_reservation_wage_direct(params, v_iv = someNewThing).

The reason we do it this way, instead of just defining v_iv as a hardcoded value inside the function, is to allow the user to change it/make the method more flexible.

Hopefully this helps. Please let me know if something is unclear. And no need to apologize for an earnest question; that is why the forum exists.

Yours,
Arnav

Edit: Also, if the Discourse is to be believed, happy birthday.


#3

Thank you so much @ arnavs for the clear explanation, I really appreciate it. Just to make sure I’ve understood correctly; for the ‘usual’ McCall model when we discount wages in the infinite future the value is \frac{w}{1-\beta} but this need not always be the case. So using v_iv = w/(1-b) is just one specification. If instead we were in two period model, I would set v_iv = collect(w(1+beta)) for example.

That’s actually quite clever! Thank you once again for explaining this to me :slight_smile:


#4

More like, the v_iv is not a model feature, but is instead an educated guess (per the contraction mapping theorem, iterating on any element of the space will lead us, eventually, to the neighborhood of the fixed point).

The thing is, the contraction mapping theorem as we’ve applied it (i.e., start somewhere and iterate) doesn’t tell us much about the speed of convergence. If we start somewhere far away, it may be ages before we get to a reasonable answer. We know that w/(1-\beta) has something to do with the value (since it’s the lifetime value of accepting a wage, and eventually we will probably be accepting wages). So we pick it as a starting point.

tl;dr the choice of initial condition is entirely numerical. Nothing in the “model” says anything about iteration, contractions, initial values, etc. This is purely something that comes out of the code required to actually compute the equilibrium objects.


#5

That makes sense. I am still not very confident with the proof of the contraction mapping theorem but after reading the lecture and your comment, I kind of see the point of v_iv now. Thank you so much @ arnavs.


#6

No problem.

And as for proving the contraction mapping theorem, I’ll let you write up the exercise :-). But it was helpful for me to translate the theorem into English.

What it says is that, if I have a non-empty metric space that’s complete (i.e., has no “holes” or every Cauchy sequence has a limit), and if I have a strict contraction (i.e., a function such that f(x), f(y) are always closer together than x, y), then if I keep iterating on a point, I’ll eventually end up at a (unique) fixed point.

It may be helpful to look at the sequence x, T(x), T^2(x), .... Is it Cauchy? What’s the limit? Is the limit contingent on the choice of x? Is it possible for a sequence to have a non-unique limit?

Hope this helps.

Yours,
Arnav


#7

You’re amazing @arnavs! I can’t thank you enough for that explanation. I have one last question regarding this lecture: We start off by looking at the distribution of wages (which follow a binomial distribution):

dist = BetaBinomial(n, 200, 100) # probability distribution
w = range(10.0, 60.0, length = n+1) # linearly space wages

But in these lines, I don’t really see that we are saying that the wages are drawn from a binomial distribution. We have defined

dist

to follow the distribution but w is simply an array of numbers, correct? I don’t really see how we have connected the wages to their distribution.


#8

Hey @Gensys,

Good question. The key is in our definition of the expectation operator:

E = expectation(dist) # expectation operator

This is the object that contains the distribution information. Otherwise you’re entirely correct — the wage vector, on its own, could adhere to any (discrete) distribution on the right set of nodes.

Note that we use this distribution later for functions of the wage nodes, e.g. in defining the object

E*max.((w ./ (1 - β)), ψ)

which is the expectation

\mathbb{E}\left[\max\left\{\frac{w}{1-\beta}, \psi\right\}\right]

where w is distributed as specified.


#9

Ah of course! Can’t believe I missed that. Thanks once again for all the help @ arnavs.