Structural Econometrics - Assignment 1 Tutorial

Author: Jaepil Lee

October 21, 2021

Preliminary: Beta Distribution and Conjugate Prior

Static Problem

Dynamic Problem: 2 periods

Dyanmic Problem: Infinite horizon

The model in this assignment is summarized as follows:

Preliminary: Beta Distribution and Conjugate Prior

Suppose $\xi\sim\text{Beta}(\gamma, \delta)$. Then we have the following properties:

If the agent invents, she will get the result of inventing, either success or failure. Based on the result, she will update her belief about her ability by updating her parameters $(\gamma, \delta)$ via Bayes' rule.

Statisticians found many cases where the prior distribution and posterior distribution are in the same distribution family after Bayesian update. The prior distribution in this case is called a conjugate prior for the likelihood function. In Miller (1984), the conjugate prior is a normal distribution and the likelihood is also a normal distribution. In this assignment, the conjugate prior is a beta distribution and the likelihood is a Bernoulli distribution.

The prior distribution of $\xi$ given parameters $(\gamma, \delta)$ is $$ g(\xi;\gamma,\delta)=\frac{\xi^{\gamma-1} (1-\xi)^{\delta-1}}{\text{B}(\gamma,\delta)} \text{ where } \text{B}(\gamma,\delta)=\int_{0}^{1} u^{\gamma-1}(1-u)^{\delta-1}du $$ and the likelihood of the outcome $x\in\{0,1\}$ given $\xi$ is $$ f(x\,|\,\xi)= \xi^{x} (1-\xi)^{1-x}. $$ The agent's posterior belief is derived by using Bayes' rule: $$ \begin{split} f(\xi|x)& =\frac{f(x|\xi)}{f(x)}g(\xi)=\frac{f(x|\xi)}{\int_{0}^{1}f(x|\xi)g(\xi)d\xi}g(\xi)= \frac{\xi^{x}(1-\xi)^{1-x}}{\int_{0}^{1}\xi^{x}(1-\xi)^{1-x}\frac{{\xi}^{\gamma-1}(1-\xi)^{\delta-1}}{\text{B}(\gamma,\delta)}d\xi}\frac{\xi^{\gamma-1}(1-\xi)^{\delta-1}}{\text{B}(\gamma,\delta)}\\ & = \frac{\xi^{\gamma+x-1}(1-\xi)^{\delta+(1-x)-1}}{\int_{0}^{1}\xi^{\gamma+x-1}(1-\xi)^{\delta+(1-x)-1}d\xi}= \frac{\xi^{\gamma+x-1}(1-\xi)^{\delta+(1-x)-1}}{\text{B}(\gamma+x,\delta+(1-x))} \end{split} $$ Therefore, the agent's updated belief about her ability follows a beta distribution with parameters $(\gamma+x,\delta+(1-x))$.

The updated expected payoff is then: $$ \mathbb{E}[\mathbf{1}\{x'=1\}|\gamma',\delta'] = \frac{\gamma'}{\gamma' + \delta'} = \begin{cases} \frac{\gamma}{\gamma + (\delta+1)} & \text{ if } x=0\\ \frac{\gamma+1}{(\gamma+1) + \delta} & \text{ if } x=1 \end{cases} $$ If the agent chooses not to invent, then there will be no update on her parameters (there is no information to update the parameters). Thus, the agent's belief about her ability in the next period will still be $\xi \sim \text{Beta}(\gamma, \delta)$. i.e., the agent solves the recursive problem in the next period with the same parameters.

Static problem

Let's start with a simple setting. Let's suppose that we are solving a static model. In this case the lifetime utility is $$d_t\mathbf{1} \{x_t=1\} + (1-d_t)w.$$

If we knew the exact value of $\xi$, then the decision rule is simple: we choose to invent if the expected payoff of invention is larger than the payoff of the outside option given $\xi$: $$ \mathbb{E}_{x}\big[1\cdot\mathbf{1}\{x=1\}+0\cdot\mathbf{1}\{x=0\}|\xi]=1\cdot\mathbb{P}(x=1|\xi) + 0\cdot\mathbb{P}(x=0|\xi) = \xi. $$ In this case, the decision rule would be: $$d_t=\begin{cases} 1 &\text{ if } \xi>w \\ 0 &\text{ otherwise } \end{cases}$$

However, the agent only knows that her ability $\xi$ is a random draw from a beta distribution $\text{Beta}(\gamma,\delta)$, not its exact value. As a risk-neutral agent, the agent would compute her expected return on inventing and decide whether it is worth trying or not. $$ \mathbb{E}_{\xi} \Big[\mathbb{E}_{x} \big[ \mathbf{1}\{x=1\} \big| \xi \big] \Big|\gamma,\delta\Big] =\mathbb{E}_{\xi} \big[1 \cdot \mathbb{P}(x=1|\xi) + 0 \cdot \mathbb{P}(x=0|\xi) \big| \gamma,\delta \big] =\mathbb{E}_{\xi} [1 \cdot \xi + 0 \cdot (1-\xi) | \gamma,\delta] = \mathbb{E}_{\xi}[{\xi}|\gamma,\delta]=\frac{\gamma}{\gamma+\delta}. $$ The decision rule is then: $$ d_t=\begin{cases} 1 &\text{ if } \frac{\gamma}{\gamma+\delta}>w \\ 0 &\text{ otherwise } \end{cases} $$

Let's make simulated data of $N$ agents with this decision rule!

By now, you might have noticed that in the static case, everyone makes the same choice! This is because in the first period, everyone has the same belief about their ability. As agents try out inventing and finds more about their ability, we will see that people making different choices.

Given the data where everyone making the same choice (i.e., all zeros or all ones), we cannot point-identify any parameter of the set of parameters $(\gamma,\delta,w)$. Let's take a step back and look at the decision rule: $$ d_t=\begin{cases} 1 &\text{ if } \frac{\gamma}{\gamma+\delta}>w \\ 0 &\text{ otherwise } \end{cases} $$

Dynamic Problem: 2 Periods

Let's solve the two-period model. The lifetime utility is now $\sum_{t=1}^{2} \beta^{t-1} [d_t\mathbf{1} \{x_t=1\} + (1-d_t)w]$. The state variables in each period are $(\gamma_t,\delta_t,w,t,\beta)$.

Let's solve this model by backward induction. At $t=2$, the agent observes $(\gamma_{2},\delta_{2},w,2,\beta)$ and solves $ \underset{d_{2}\in\{0,1\}}{\max}\;\mathbb{E}_{\xi_2}\Big[\mathbb{E}_{x_2}\big[d_2\mathbf{1} \{x_2=1\} + (1-d_2)w\big|\xi_2\big]\Big|\gamma_2,\delta_2\Big]. $ It is straightforward that at $t=2$, the agent will choose to invent whenever the expected payoff of inventing is higher than choosing the outside option. We also derived that $\mathbb{E}_{\xi_2}\Big[\mathbb{E}_{x_2}\big[\mathbf{1}\{x_{2}=1\}\big|\xi_2\big]\Big|\gamma_2,\delta_2\Big] = \frac{\gamma_2}{\gamma_2 + \delta_2}$. Thus, the decision rule at $t=2$ becomes: $\begin{align*} d_{2}(\gamma_2,\delta_2,w)=\begin{cases} 1 & \text{if } \frac{\gamma_2}{\gamma_2 + \delta_2}> w\\ 0 & \text{if } \frac{\gamma_2}{\gamma_2 + \delta_2}\leq w \end{cases} = \mathbf{1}\left\{\frac{\gamma_2}{\gamma_2 + \delta_2}> w\right\}. \end{align*}$

Plugging the decision rule into the maximization problem, the expected value function at $t=2$ becomes: $$\begin{align*} V(\gamma_2,\delta_2,w,2,\beta) &= \underset{d_{2}\in\{0,1\}}{\max}\;\mathbb{E}_{\xi_2}\Big[\mathbb{E}_{x_2}\big[d_2\mathbf{1} \{x_2=1\} + (1-d_2)w\big|\xi_2\big]\Big|\gamma_2,\delta_2\Big] \\ &= d_2(\gamma_2,\delta_2,w)\mathbb{E}_{\xi_2}\Big[\mathbb{E}_{x_2}\big[\mathbf{1}\{x_{2}=1\}\big|\xi_2 \big]\Big|\gamma_2,\delta_2\Big] + (1-d_2(\gamma_2,\delta_2,w))w \\ &= d_2(\gamma_2,\delta_2,w)\frac{\gamma_2}{\gamma_2+\delta_2} + (1-d_2(\gamma_2,\delta_2,w))w \\ &= \mathbf{1}\left\{\frac{\gamma_2}{\gamma_2 + \delta_2}> w\right\} \frac{\gamma_2}{\gamma_2+\delta_2} + \left(1-\mathbf{1}\left\{\frac{\gamma_2}{\gamma_2 + \delta_2}> w\right\}\right) w \end{align*}$$

Knowing the decision rule $d_{2}(\gamma_2,\delta_2,w)$, we can solve for the agent's choice at $t=1$. At $t=1$, the agent maximizes her expectation of the discounted present value of the lifetime payoff: $$ \begin{align*} V(\gamma_1,\delta_1,w,1,\beta) = \underset{d_{1}\in\{0,1\}}{\max}\; \mathbb{E}_{\xi_1}\Big[&\mathbb{E}_{x_1}[d_1\mathbf{1}\{x_{1}=1\}+(1-d_{1})w|\xi_1\big]\Big|\gamma_1,\delta_1\Big] \\ +\beta \Bigg(&d_1\mathbb{E}_{\xi_1}\Big[\mathbb{E}_{x_1}\Big[\mathbf{1}\{x_1=0|\gamma_1,\delta_1\}V(\gamma_2,\delta_2,w,2)\Big|\xi_1\Big]\Big|\gamma_1,\delta_1\Big]+\\ &d_1\mathbb{E}_{\xi_1}\Big[\mathbb{E}_{x_1}\Big[\mathbf{1}\{x_1=1|\gamma_1,\delta_1\}V(\gamma_2,\delta_2,w,2)\Big|\xi_1\Big]\Big|\gamma_1,\delta_1\Big]+\\ &(1-d_1)V(\gamma_2,\delta_2,w,2)\Bigg) \end{align*} $$ where $(\gamma_2,\delta_2)$ are updated by the following rule: $$ \begin{align*} (\gamma_2,\delta_2) = \begin{cases} (\gamma_1+1, \delta_1) &\text{if } d_1=1, x_1 =1\\ (\gamma_1, \delta_1+1) &\text{if } d_1=1, x_1 =0 \\ (\gamma_1, \delta_1) &\text{if } d_1=0 \end{cases}. \end{align*} $$

Noting that $\mathbb{E}_{\xi_1}[\mathbb{P}[x_1=1|\xi_1]\big|\gamma,\delta]=\frac{\gamma}{\gamma+\delta}$ and $\mathbb{E}_{\xi_1}[\mathbb{P}[x_1=0|\xi_1]\big|\gamma,\delta]=\frac{\delta}{\gamma+\delta}$, we rewrite the value function as: $$ \begin{equation*} \begin{split} V(\gamma,\delta,w,1,\beta) = \underset{d_{1}}{\max}\; d_{1}\frac{\gamma}{\gamma+\delta}+(1-d_{1})w +\beta \left[d_1\frac{\gamma}{\gamma+\delta}V(\gamma+1,\delta,w,2)+d_1\frac{\delta}{\gamma+\delta}V(\gamma,\delta+1,w,2)+(1-d_1)V(\gamma,\delta,w,2)\right] \end{split} \end{equation*} $$

Finally, we use $V(\gamma_2,\delta_2,w,2,\beta)=\mathbf{1}\left\{\frac{\gamma_2}{\gamma_2 + \delta_2}> w\right\}\cdot \frac{\gamma_2}{\gamma_2+\delta_2} + \left(1-\mathbf{1}\left\{\frac{\gamma_2}{\gamma_2 + \delta_2}> w\right\}\right)\cdot w$ to find the expression for $V(\gamma,\delta,w,1,\beta)$ with only $\gamma,\delta,w$, and $d_1$: $$ \begin{align*} V(\gamma,\delta,w,1,\beta) = \max_{d_{1}} \; d_{1}\frac{\gamma}{\gamma+\delta}+(1-d_{1})w + \beta\bigg[&d_1\frac{\gamma}{\gamma+\delta}\left(\mathbf{1}\left\{\frac{\gamma+1}{\gamma+\delta+1}> w\right\} \frac{\gamma+1}{\gamma+\delta+1} + \mathbf{1}\left\{\frac{\gamma+1}{\gamma + \delta +1}\leq w\right\} w\right)+\\ &d_1\frac{\delta}{\gamma+\delta}\left(\mathbf{1}\left\{\frac{\gamma}{\gamma + \delta +1}>w\right\} \frac{\gamma}{\gamma+\delta+1} + \mathbf{1}\left\{\frac{\gamma}{\gamma+\delta+1}\leq w\right\} w\right)+\\ &(1-d_1)\left(\mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}> w\right\} \frac{\gamma}{\gamma+\delta} + \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}\leq w\right\} w\right)\bigg] \end{align*} $$

Side note: we could write in this way only because we had two periods. If you have more than two periods you may want to prepare a mapping from a state space to the decision for each period. In this case, storing a function $d_t=\mathbf{1}(\gamma,\delta,w,t)$ in a discretized state space for each time period $t$ may be necessary. If you have an infinite horizon, the dimension for time goes away and you may only need to find $d = \mathbf{1}(\gamma,\delta,w)$, which we shall see later.

Can you find $w^*$, the upper bound of $w$, that ensures for every $w<w^*$, everyone invents in the first period? From the optimization problem in the first period, $d_1=1$ if the value of the value function when choosing $d_1=1$ is larger than or equal to that when choosing $d_1=0$: $$ \begin{aligned} \frac{\gamma}{\gamma+\delta}+\beta\bigg[ &\frac{\gamma}{\gamma+\delta}\left(\mathbf{1}\left\{\frac{\gamma+1}{\gamma+\delta+1}> w\right\} \frac{\gamma+1}{\gamma+\delta+1} + \mathbf{1}\left\{\frac{\gamma+1}{\gamma + \delta +1}\leq w\right\} w\right)+ \\ &\frac{\delta}{\gamma+\delta}\left(\mathbf{1}\left\{\frac{\gamma}{\gamma + \delta +1}> w\right\} \frac{\gamma}{\gamma+\delta+1} + \mathbf{1}\left\{\frac{\gamma}{\gamma+\delta+1}\leq w\right\} w\right)\bigg] \\ &\geq w+\beta\left(\mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}> w\right\} \frac{\gamma}{\gamma+\delta} + \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}\leq w\right\} w\right) \end{aligned} $$

$w$ is compared to three quantities $\frac{\gamma}{\gamma+\delta}$,$\frac{\gamma+1}{\gamma+\delta+1}$, $\frac{\gamma}{\gamma+\delta+1}$ inside the indicator functions. It is clear that $\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}$. Thus, we have four cases to consider:

  1. $w<\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}$
  2. $\frac{\gamma}{\gamma+\delta+1}\leq w<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}$
  3. $\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}\leq w<\frac{\gamma+1}{\gamma+\delta+1}$
  4. $\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}\leq w$
  1. $w<\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}$ The following shows the values for indicator functions: $$ \begin{align*} \mathbf{1}\left\{\frac{\gamma+1}{\gamma+\delta+1}> w\right\}=1 &\text{ and } \mathbf{1}\left\{\frac{\gamma+1}{\gamma + \delta +1}\leq w\right\}=0,\\ \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta +1}> w\right\}=1 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma+\delta+1}\leq w\right\}=0,\\ \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}> w\right\}=1 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta} \leq w \right\}=0 \end{align*} $$ Plugging these values into the inequality above, $d_1=1$ if: $$ \begin{align*} \frac{\gamma}{\gamma+\delta}+\beta\bigg[\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}+\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\bigg] &\geq w+\beta\bigg[\frac{\gamma}{\gamma+\delta}\bigg]\\ \frac{\gamma}{\gamma+\delta}&\geq w \end{align*} $$ Thus, if $w<\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}$, everyone will choose to invent.

  2. $\frac{\gamma}{\gamma+\delta+1}\leq w<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}$ The following show the values for indicator functions: $$ \begin{align*} \mathbf{1}\left\{\frac{\gamma+1}{\gamma+\delta+1}> w\right\}=1 &\text{ and } \mathbf{1}\left\{\frac{\gamma+1}{\gamma + \delta +1}\leq w\right\}=0,\\ \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta +1}> w\right\}=0 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma+\delta+1}\leq w\right\}=1,\\ \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}> w\right\}=1 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta} \leq w \right\}=0 \end{align*} $$ Plugging these values into the inequality above, $d_1=1$ if: $$ \begin{align*} d_1=1 \text{ if } \frac{\gamma}{\gamma+\delta}+\beta\bigg[\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}+\frac{\delta}{\gamma+\delta}w\bigg]&\geq w+\beta\bigg[\frac{\gamma}{\gamma+\delta}\bigg]\\ \frac{\gamma}{\gamma+\delta}\frac{1-\frac{\beta\delta}{\gamma+\delta+1}}{1-\frac{\beta\delta}{\gamma+\delta}}&\geq w \end{align*} $$ Thus, everyone will choose to invent if $\frac{\gamma}{\gamma+\delta+1}\leq w<\min\{\frac{\gamma}{\gamma+\delta},\frac{\gamma}{\gamma+\delta}\frac{1-\frac{\beta\delta}{\gamma+\delta+1}}{1-\frac{\beta\delta}{\gamma+\delta}}\}=\frac{\gamma}{\gamma+\delta}$

  3. $\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}\leq w<\frac{\gamma+1}{\gamma+\delta+1}$ The following show the values for indicator functions: $$ \begin{align*}

     \mathbf{1}\left\{\frac{\gamma+1}{\gamma+\delta+1}> w\right\}=1 &\text{ and } \mathbf{1}\left\{\frac{\gamma+1}{\gamma + \delta +1}\leq w\right\}=0,\\
     \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta +1}> w\right\}=0 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma+\delta+1}\leq w\right\}=1,\\
     \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}> w\right\}=0 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta} \leq w \right\}=1
    

    \end{align} $$ Plugging these values into the inequality above, $d_1=1$ if: $$ \begin{align} d_1=1 \text{ if } \frac{\gamma}{\gamma+\delta}+\beta\bigg[ \frac{\gamma}{\gamma+\delta} \frac{\gamma+1}{\gamma+\delta+1} +\frac{\delta}{\gamma+\delta} w \bigg] &\geq w+\beta w \ \frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}&\geq w \end{align*} $$ Thus, everyone will choose to invent if $\frac{\gamma}{\gamma+\delta}\leq w<\min{\frac{\gamma+1}{\gamma+\delta+1},\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}}=\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}$.

  4. $\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}\leq w$ The following show the values for indicator functions: $$ \begin{align*} \mathbf{1}\left\{\frac{\gamma+1}{\gamma+\delta+1}> w\right\}=0 &\text{ and } \mathbf{1}\left\{\frac{\gamma+1}{\gamma + \delta +1}\leq w\right\}=1,\\ \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta +1}> w\right\}=0 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma+\delta+1}\leq w\right\}=1,\\ \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta}> w\right\}=0 &\text{ and } \mathbf{1}\left\{\frac{\gamma}{\gamma + \delta} \leq w \right\}=1 \end{align*} $$ Plugging these values into the inequality above, $d_1=1$ if: $$ \begin{align*} \frac{\gamma}{\gamma+\delta}+\beta\bigg[\frac{\gamma}{\gamma+\delta}w + \frac{\delta}{\gamma+\delta} w \bigg] &\geq w+\beta w \\ \frac{\gamma}{\gamma+\delta} &\geq w \end{align*} $$ We have contradiction: $\frac{\gamma}{\gamma+\delta+1}<w$ and $\frac{\gamma}{\gamma+\delta} \geq w$. Thus, there is no $w$ that can make everyone choose $d_1=1$ if $\frac{\gamma}{\gamma+\delta+1}<\frac{\gamma}{\gamma+\delta}<\frac{\gamma+1}{\gamma+\delta+1}\leq w$.

To sum up, everyone will choose to invent at $t=1$ if $w<\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}=w^*$.

Let's code what we discussed so far. Instead of writing a bunch of indicator functions, I want to be lazy here and tell the program to find out the decision rule to the maximization problem on its own via backward induction. This is convenient because this allows us to easily extend the program to a finite horizon model with any size $T$.

We start from the last period, $t=2$. In this period, we do not have any continuation value to think about; the maximization problem only has today's per-period utility. The value function and the policy function here are straightforward: $$ \begin{aligned} V(\gamma,\delta,w,2,\beta) &= \underset{d\in\{0,1\}}{\max} \quad\; d \frac{\gamma}{\gamma+\delta}+ (1-d) w\\ d(\gamma,\delta,w,2,\beta) &= \underset{d\in\{0,1\}}{\arg\max} \; d \frac{\gamma}{\gamma+\delta}+ (1-d) w\\ \end{aligned} $$ The policy function and the value function at $t=1$ simply take the value function and the policy function we found at $t=2$ and return the solution and the maximized value to the maximization problem: $$ \begin{aligned} V(\gamma,\delta,w,1,\beta) = \underset{d\in\{0,1\}}{\max} &d \frac{\gamma}{\gamma+\delta}+ (1-d) w + \beta \Bigg(d\left(\frac{\gamma}{\gamma+\delta} V(\gamma+1,\delta,w,2,\beta)+ \frac{\delta}{\gamma+\delta} V(\gamma,\delta+1,w,2,\beta) \right) + (1-d) V(\gamma,\delta,w,2,\beta)\Bigg) \\ d(\gamma,\delta,w,1,\beta) = \underset{d\in\{0,1\}}{\arg\max} &d \frac{\gamma}{\gamma+\delta}+ (1-d) w + \beta \Bigg(d\left(\frac{\gamma}{\gamma+\delta} V(\gamma+1,\delta,w,2,\beta)+ \frac{\delta}{\gamma+\delta} V(\gamma,\delta+1,w,2,\beta) \right) + (1-d) V(\gamma,\delta,w,2,\beta)\Bigg) \\ \end{aligned} $$

Side note: you can "solve and take note of" the solution to the model by telling the program to return the decision at $t$ given state variables $(\gamma,\delta,w,\beta)$ and store them in DataFrames or in an Array (memoization) while doing backward induction. I will not do that here because the computation is cheap in our case. You may want to do this when the state space or time horizon becomes large.

Generating data based on this decision is also simple.

We can use $w^*=\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}$ and choice-specific conditional value function to check if our program is well-written. Choice-specific conditional value function is a discounted present value of lifetime utility if an agent commits to a certain choice today and behaves optimally in the periods that follow. In our case, there are two choice-specific conditional value functions at $t=1$: $$ \begin{align*} v_0(\gamma,\delta,w,1,\beta) &= w + \beta V(\gamma,\delta,w,2,\beta) \\ v_1(\gamma,\delta,w,1,\beta) &= \frac{\gamma}{\gamma+\delta}+ \beta \Bigg(\frac{\gamma}{\gamma+\delta} V(\gamma+1,\delta,w,2,\beta)+ \frac{\delta}{\gamma+\delta} V(\gamma,\delta+1,w,2,\beta) \Bigg) \end{align*} $$ We can put $w^*=\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}$ to our choice-specific conditional value functions and check if they have the same value, which is precisely what we expect from the definition of $w^*$.

Let's suppose we only observe the agent's choice at $t = 2$. From the data, we can only talk about the fraction of agents quit inventing at $t=2$ condtional on the agents had tried inventing at $t=1$. Theoretically, we can think of the following cases: $$ \begin{align*} \mathbb{P}(d_2=0|d_1=1)=\begin{cases} 0 &\text{ if } w<w^* \text{ and } w<\frac{\gamma}{\gamma+\delta+1} \\ \alpha &\text{ if } w<w^* \text{ and } \frac{\gamma}{\gamma+\delta+1}<w \text{ where } \alpha\in(0,1) \\ 1 &\text{ if } w<w^* \text{ and } w>\frac{\gamma+1}{\gamma+\delta+1} \end{cases} \end{align*} $$

We can easily show that the third case is impossible. Thus, we consider two cases:

  1. $\mathbb{P}(d_2=0|d_1=1)=0$; i.e., we only observe ones in the data.
    • This can happen if $w<w^*$ and $w<\frac{\gamma}{\gamma+\delta+1}$ (which implies $w<\frac{\gamma}{\gamma+\delta+1}$). We may only suggest some bounds to one of the parameters given specific values of the other parameters with this condition.
    • For example, if we know exact values of $\gamma$ and $\delta$, we can only say that $w$ is less than $\frac{\gamma}{\gamma+\delta+1}$. Even then, any values of $\beta\in(0,1)$ can generate the same data so we cannot identify $\beta$.
  2. $\mathbb{P}(d_2=0|d_1=1)=\alpha$; i.e., we observe some zeros and some ones in the data.
    • This can happen if $w<w^*$ and $\frac{\gamma}{\gamma+\delta+1}<w$.
    • If we are given the exact values of all but one of $(\gamma,\delta,w,\beta)$, then how can we identify the remaining parameter?
      • If we are asked to identify either $\gamma$ or $\delta$, then we can use our knowledge that $\mathbb{E}[\mathbf{1}\{d_{2i}=1\}]=\frac{\gamma}{\gamma+\delta}$ (details below).
      • If we are asked to identify $w$ or $\beta$, we can only identify up to some bounds:
        • For $w$, we can only say that $\frac{\gamma}{\gamma+\delta+1}<w<\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}$.
        • For $\beta$, we can only say that $w<\frac{\gamma}{\gamma+\delta}\frac{1+\beta\frac{\gamma+1}{\gamma+\delta+1}}{1+\beta\frac{\gamma}{\gamma+\delta}}$, i.e., $\frac{(\gamma+\delta+1)(w\gamma+w-\gamma)}{\gamma(\gamma+1-w(\gamma+\delta+1))}<\beta$.

Identifying $\gamma$ or $\delta$ is more interesting, so let's focus on identifying and estimating $\gamma$ via MLE. Let's suppose we are given $(\delta,w,\beta,\{d_{2i}\}_{i=1}^N)$ and are asked to identify and estimate $\gamma$. From the model, we know: $$ d_{2i}=\mathbf{1} \bigg\{ \mathbb{E}_{\xi_2}\bigg[\mathbb{E}_{x_2}\big[ \mathbf{1}\{x_2=1\}\big|\xi_2\big]\Big|\gamma,\delta,x_1 \bigg] > w \bigg\} $$ i.e., $d_2$ is chosen by comparing the expected payoff of inventing which depends on our updated belief to the payoff of the outside option. The probability of observing $d_{2i}=1$, $\mathbb{E}[\mathbf{1}[d_{2i}=1]]$, is then: $$ \begin{align*} \mathbb{E} \left[\mathbf{1}[d_{2i}=1]\right] =& \mathbb{E} \Bigg[\mathbf{1} \bigg\{ \mathbb{E}_{\xi_2}\Big[\mathbb{E}_{x_2}\big[ \mathbf{1}\{x_2=1\}\big|\xi_2\big]\Big|\gamma,\delta,x_1 \Big] > w \bigg\}\Bigg] = \mathbb{E} \bigg[ \mathbf{1} \Big\{ \mathbb{E}_{\xi_2}\big[ 1\cdot\xi_{2}+0\cdot(1-\xi_{2})\big|\gamma,\delta,x_1 \big] > w \Big\} \bigg] = \mathbb{P} \Big[ \mathbb{E}_{\xi_2} \big[\xi_{2};\gamma,\delta\big] > w \Big]\\ =& \mathbb{P} \Big[ \mathbb{E}_{\xi_2}\big[\xi_{2};\gamma,\delta,x_1\big] > w \big| d_{1}=1, x_1=1 \Big] \cdot \mathbb{P} \Big[ d_{1}=1, x_1=1 \Big] + \mathbb{P} \Big[ \mathbb{E}_{\xi_2}\big[\xi_{2};\gamma,\delta,x_1\big] > w \big| d_{1}=1, x_1=0 \Big] \cdot \mathbb{P} \Big[ d_{1}=1, x_1=0 \Big] \\ +& \mathbb{P} \Big[ \mathbb{E}_{\xi_2}\big[\xi_{2};\gamma,\delta,x_1\big] > w \big| d_{1}=0 \Big] \cdot \mathbb{P} \Big[ d_{1}=0 \Big] \end{align*} $$

We saw that $w<w^{*} \implies d_1=1$. Since we are considering a dataset where we guarantee agents to invent in the first period, we have $\mathbb{P}[d_1=0]=0.$ Thus, the following holds: $$ \begin{align*} \mathbb{E} \left[\mathbf{1}[d_{2i}=1]\right] = &\mathbb{P} \Big[ \mathbb{E}_{\xi_2} \big[ \xi_{2}; \gamma,\delta,x_1 \big] \geq w \bigm| d_{1}=1, x_1=1 \Big] \cdot \mathbb{P} \Big[d_{1}=1, x_1=1 \Big]+ \mathbb{P} \Big[ \mathbb{E}_{\xi_2}\big[\xi_{2};\gamma,\delta,x_1\big] \geq w \bigm| d_{1}=1, x_1=0 \Big] \cdot \mathbb{P} \Big[d_{1}=1, x_1=0 \Big]\\ = &\mathbb{P} \bigg[ \frac{\gamma+1}{\gamma+\delta+1} \geq w \bigg] \cdot \frac{\gamma}{\gamma+\delta} + \mathbb{P} \bigg[ \frac{\gamma}{\gamma+\delta+1} \geq w \bigg] \cdot \frac{\delta}{\gamma+\delta} = \frac{\gamma}{\gamma+\delta} \quad \because w<w^*<\frac{\gamma+1}{\gamma+\delta+1} \text{ and } \frac{\gamma}{\gamma+\delta+1}<w. \end{align*} $$

In words, we know that the agent would choose to invent in the second period if invention was successful in the first period. We also know that the probability of success follows a beta distribution $\text{Beta}(\gamma,\delta)$ with expected value $\frac{\gamma}{\gamma+\delta}$. Thus, the likelihood of observing an agent inventing in the second period given $(\gamma,\delta)$ is $\frac{\gamma}{\gamma+\delta}$.

The flipside of this argument is hazard rate at $t=2$. The probability of agent choosing to quit in the second period is $\frac{\delta}{\gamma+\gamma}$. I suggest you use the similar reasoning I provided above and convince yourself that the hazard rate is indeed $\frac{\delta}{\gamma+\gamma}$.

The discussion above motivates to construct the likelihood of $\{d_{i2}\}_{i=1}^{N}$ by: $$ \begin{align*} \mathcal{L}(\gamma;\{d_{i2}\}_{i=1}^{N},\delta)=\prod_{i=1}^{N}\left(\frac{\gamma}{\gamma+\delta}\right)^{d_{i2}}\left(\frac{\delta}{\gamma+\delta}\right)^{1-d_{i2}} \end{align*} $$ The log-likelihood is $$ \begin{align*} \log\mathcal{L}(\gamma;\{d_{i2}\}_{i=1}^{N},\delta)&=\sum_{i=1}^{N}\left(d_{i2}\log\left(\frac{\gamma}{\gamma+\delta}\right)+(1-d_{i2})\log\left(\frac{\delta}{\gamma+\delta}\right)\right)\\ &=\sum_{i=1}^{N}\left(d_{i2}\left(\log\gamma-\log(\gamma+\delta)\right)+(1-d_{i2})\left(\log\delta-\log(\gamma+\delta)\right)\right) \end{align*} $$

Let's exploit that $\{d_{i2}\}_{i=1}^{N}$ are independent. The score function of a single observation $d_{i2}$ is $$ \begin{align*} s(\gamma;d_{i2},\delta)=\frac{\partial}{\partial\gamma}\log f(\gamma;d_{i2},\delta)=d_{i2}\left(\frac{1}{\gamma}-\frac{1}{\gamma+\delta}\right)+(1-d_{i2})\left(-\frac{1}{\gamma+\delta}\right) \end{align*} $$ This gives us the derivative of the log-likelihood with respect to $\gamma$: $$ \begin{align*} \frac{\partial}{\partial\gamma}\log \mathcal{L}(\gamma;\{d_{i2}\}_{i=1}^{N},\delta)=\sum_{i=1}^{N}\left(d_{i2}\left(\frac{1}{\gamma}-\frac{1}{\gamma+\delta}\right)+(1-d_{i2})\left(-\frac{1}{\gamma+\delta}\right)\right) \end{align*} $$

Setting above to zero and solve for $\gamma$ will give us the estimate of $\gamma$ via MLE: $$ \begin{align*} \sum_{i=1}^{N}\left(d_{i2}\left(\frac{1}{\gamma}-\frac{1}{\gamma+\delta}\right)+(1-d_{i2})\left(-\frac{1}{\gamma+\delta}\right)\right) &= 0 \\ \left(\frac{1}{\gamma}-\frac{1}{\gamma+\delta}\right)\sum_{i=1}^{N}d_{i2} -\frac{N}{\gamma+\delta} + \frac{1}{\gamma+\delta}\sum_{i=1}^{N}d_{i2}&= 0 \\ \frac{1}{\gamma}\sum_{i=1}^{N}d_{i2} = \frac{N}{\gamma+\delta}&\\ \therefore \hat{\gamma} = \frac{\delta\sum_{i=1}^{N}d_{i2}}{N-\sum_{i=1}^{N}d_{i2}}& \end{align*} $$

$\{d_{i2}\}_{i=1}^{N}$ are i.i.d. so I use the following theorem to compute the Fisher information: $$ \begin{align*} I_{N}(\gamma)&=N\cdot I(\gamma)=-N\cdot \mathbb{E}_{\gamma}\left(\frac{\partial^2\log f(\gamma;d_{i2},\delta)}{\partial \gamma^2}\right)\\ &=-N\cdot\mathbb{E}_{\gamma}\left( d_{i2}\left(-\frac{1}{\gamma^2}+\frac{1}{(\gamma+\delta)^2}\right)+(1-d_{i2})\left(\frac{1}{(\gamma+\delta)^2}\right)\right)\\ &=-N\cdot\left(\left(-\frac{1}{\gamma^2}+\frac{1}{(\gamma+\delta)^2}\right)\frac{\gamma}{\gamma+\delta}+\left(\frac{1}{(\gamma+\delta)^2}\right)\frac{\delta}{\gamma+\delta}\right) \\ &=\frac{N\delta}{\gamma(\gamma+\delta)^2} \end{align*} $$ Substituting $\gamma$ with $\hat{\gamma}$, we have asymptotic normality of the MLE as follows: $$ \begin{align*} &\hat{se} = \sqrt{1/I_N(\hat{\gamma})}\\ &\frac{\hat{\gamma}-\gamma}{\hat{se}} \xrightarrow{d} N(0,1) \end{align*} $$ Coding the likelihood and the estimation routine based on our derivation is straightforward:

Code below shows the estimation result using various sample sizes. I also included using Optim.jl, a Julia package for various optimization routines to find the MLE estimate. As you can see, using Optim.jl returns the identical result as it should. Since analytically solving for the MLE as $T$ gets large in the finite horizon case or in the infinite horizon case is impossible, we will use Optim.jl in the next section.

Dynamic Problem: Infinite Horizon

Suppose now that individuals live forever. The lifetime utility is now $\sum_{t=1}^{\infty}\beta^{t-1}(d_t\mathbf{1} \{x_t=1\} + (1-d_t)w)$.

We consider the Bellman representation: $$ \begin{align*} V(\gamma,\delta,w)=\underset{d\in\{0,1\}}{\max}\; d \frac{\gamma}{\gamma+\delta} + (1-d)w + \beta \left(d\left(\frac{\gamma}{\gamma+\delta}V(\gamma+1,\delta,w)+\frac{\delta}{\gamma+\delta}V(\gamma,\delta+1,w)\right)+(1-d)V(\gamma,\delta,w)\right) \end{align*} $$ The following code shows value function iteration (VFI) and data simulation.

VFI

Data simulation

I set $\gamma=2.3, \delta=2.0, w=0.65, \beta=0.96, N=100000$ here for an illustration.

Let's take a look at the policy function and the value function we found via VFI.

The figures below are the fraction of agents trying at $t$ and the hazard rate at $t$.

Hazard Rate and MLE

Notation:

$$ \begin{align*} h_1(\gamma,\delta)=&\mathbb{P}(\text{The agent quits at }t=1)\\ =&\mathbb{E}(1-d(\gamma,\delta)) \end{align*} $$

We are going to generate the data so that everyone tries inventing at $t=1$, so $h_1(\gamma,\delta)=0$.

$$\begin{align*} h_2(\gamma,\delta)=&\mathbb{P}(\text{The agent quits at }t=2|\text{The agent invents until } t=1 )\\ =&\frac{\mathbb{P}(\text{The agent invents until } t=1 \text{ and quits at }t=2)}{\mathbb{P}(\text{The agent invents until } t=1 )} = \frac{\mathbb{P}(\text{The agent invents until } t=1 \text{ and quits at }t=2)}{1-h_1}\\ =&\frac{1}{1-h_1}\Bigg(\mathbb{P}(\text{S,Q}) + \mathbb{P}(\text{F,Q})\Bigg)\\ =&\frac{1}{1-h_1}\Bigg(\frac{\gamma}{\gamma+\delta}d(\gamma,\delta)\Big(1-d(\gamma+1,\delta)\Big)+\frac{\delta}{\gamma+\delta}d(\gamma,\delta)\Big(1-d(\gamma,\delta+1)\Big)\Bigg) \end{align*}$$
$$ \begin{align*} h_3(\gamma,\delta) =&\mathbb{P}(\text{The agent quits at }t=3|\text{The agent invents until } t=2)\\ =&\frac{\mathbb{P}(\text{The agent invents until } t=2 \text{ and quits at }t=3)}{\mathbb{P}(\text{The agent invents until } t=2 )} = \frac{\mathbb{P}(\text{The agent invents until } t=2 \text{ and quits at }t=3)}{(1-h_1)(1-h_2)}\\ =&\frac{1}{(1-h_1)(1-h_2)}\Bigg(\mathbb{P}(\text{S,S,Q})+\mathbb{P}(\text{S,F,Q})+\mathbb{P}(\text{F,S,Q})+\mathbb{P}(\text{F,F,Q})\Bigg) \\ =&\frac{1}{(1-h_1)(1-h_2)}\times\\ \Bigg(&\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}d(\gamma,\delta)d(\gamma+1,\delta)\Big(1-d(\gamma+2,\delta)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}d(\gamma,\delta)d(\gamma+1,\delta)\Big(1-d(\gamma+1,\delta+1)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}d(\gamma,\delta)d(\gamma,\delta+1)\Big(1-d(\gamma+1,\delta+1)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\delta+1}{\gamma+\delta+1}d(\gamma,\delta)d(\gamma,\delta+1)\Big(1-d(\gamma,\delta+2)\Big)\Bigg) \end{align*} $$

Notice that at $t=3$, the proportion who tried until $t=2$ is $(1-h_1)(1-h_2)=1-h_2$. Also, the fractions inside represent the proportions of the population of agents who survived until $t=2$ and quits at $t=3$ for every possible history until $t=2$. Directly counting all possible history like this is possible only because the states are discretized. Although the summation will get more complicated, let's do this approach upto $t=5$:

$$ \begin{align*} h_4(\gamma,\delta) =& \mathbb{P}(\text{The agent quits at }t=4|\text{The agent invents until }t=3)\\ =&\frac{\mathbb{P}(\text{The agent invents until }t=3\text{ and quits at }t=4)}{\mathbb{P}(\text{The agent invents until }t=3)} =\frac{\mathbb{P}(\text{The agent invents until }t=3\text{ and quits at }t=4)}{(1-h_1)(1-h_2)(1-h_3)}\\ =&\frac{1}{(1-h_1)(1-h_2)(1-h_3)}\times\\ \Bigg(&\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\gamma+2}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+2,\delta)\Big(1-d(\gamma+3,\delta)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\delta}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+2,\delta)\Big(1-d(\gamma+2,\delta+1)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}\frac{\gamma+1}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+1,\delta+1)\Big(1-d(\gamma+2,\delta+1)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\frac{\gamma+1}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma+1,\delta+1)\Big(1-d(\gamma+2,\delta+1)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\delta+1}{\gamma+\delta+1}\frac{\gamma}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma,\delta+1)\Big(1-d(\gamma+1,\delta+2)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\frac{\delta+1}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma+1,\delta+1)\Big(1-d(\gamma+1,\delta+2)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}\frac{\delta+1}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+1,\delta+1)\Big(1-d(\gamma+1,\delta+2)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\gamma+2}{\gamma+\delta+2}d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma,\delta+2)\Big(1-d(\gamma,\delta+3)\Big)\Bigg) \end{align*} $$
$$ \begin{align*} h_5(\gamma,\delta) =& \mathbb{P}(\text{The agent quits at }t=5|\text{The agent invents until }t=4) \\ =&\frac{\mathbb{P}(\text{The agent invents until }t=4\text{ and quits at }t=5)}{\mathbb{P}(\text{The agent invents until }t=4)} = \frac{\mathbb{P}(\text{The agent invents until }t=4\text{ and quits at }t=5)}{(1-h_1)(1-h_2)(1-h_3)(1-h_4)}\\ =&\frac{1}{(1-h_1)(1-h_2)(1-h_3)(1-h_4)}\times\\ \Bigg(&\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\gamma+2}{\gamma+\delta+2}\frac{\gamma+3}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+2,\delta)d(\gamma+3,\delta)\Big(1-d(\gamma+4,\delta)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\gamma+2}{\gamma+\delta+2}\frac{\delta}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+2,\delta)d(\gamma+3,\delta)\Big(1-d(\gamma+3,\delta+1)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\delta}{\gamma+\delta+2}\frac{\gamma+2}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+2,\delta)d(\gamma+2,\delta+1)\Big(1-d(\gamma+3,\delta+1)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}\frac{\gamma+1}{\gamma+\delta+2}\frac{\gamma+2}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+1,\delta+1)d(\gamma+2,\delta+1)\Big(1-d(\gamma+3,\delta+1)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\frac{\gamma+1}{\gamma+\delta+2}\frac{\gamma+2}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma+1,\delta+1)d(\gamma+2,\delta+1)\Big(1-d(\gamma+3,\delta+1)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\gamma+1}{\gamma+\delta+1}\frac{\delta}{\gamma+\delta+2}\frac{\delta+1}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+2,\delta)d(\gamma+2,\delta+1)\Big(1-d(\gamma+2,\delta+2)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}\frac{\gamma+1}{\gamma+\delta+2}\frac{\delta+1}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+1,\delta+1)d(\gamma+2,\delta+1)\Big(1-d(\gamma+2,\delta+2)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}\frac{\delta+1}{\gamma+\delta+2}\frac{\gamma+1}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+1,\delta+1)d(\gamma+1,\delta+2)\Big(1-d(\gamma+2,\delta+2)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\delta+1}{\gamma+\delta+1}\frac{\gamma}{\gamma+\delta+2}\frac{\gamma+1}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma,\delta+2)d(\gamma+1,\delta+2)\Big(1-d(\gamma+2,\delta+2)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\frac{\delta+1}{\gamma+\delta+2}\frac{\gamma+1}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma+1,\delta+1)d(\gamma+1,\delta+2)\Big(1-d(\gamma+2,\delta+2)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\frac{\gamma+1}{\gamma+\delta+2}\frac{\delta+1}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma+1,\delta+1)d(\gamma+2,\delta+1)\Big(1-d(\gamma+2,\delta+2)\Big)+\\ &\frac{\gamma}{\gamma+\delta}\frac{\delta}{\gamma+\delta+1}\frac{\delta+1}{\gamma+\delta+2}\frac{\delta+2}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma+1,\delta)d(\gamma+1,\delta+1)d(\gamma+1,\delta+2)\Big(1-d(\gamma+1,\delta+3)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\gamma}{\gamma+\delta+1}\frac{\delta+1}{\gamma+\delta+2}\frac{\delta+2}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma+1,\delta+1)d(\gamma+1,\delta+2)\Big(1-d(\gamma+1,\delta+3)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\delta+1}{\gamma+\delta+1}\frac{\gamma}{\gamma+\delta+2}\frac{\delta+2}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma,\delta+2)d(\gamma+1,\delta+2)\Big(1-d(\gamma+1,\delta+3)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\delta+1}{\gamma+\delta+1}\frac{\delta+2}{\gamma+\delta+2}\frac{\gamma}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma,\delta+2)d(\gamma,\delta+3)\Big(1-d(\gamma+1,\delta+3)\Big)+\\ &\frac{\delta}{\gamma+\delta}\frac{\delta+1}{\gamma+\delta+1}\frac{\delta+2}{\gamma+\delta+2}\frac{\delta+3}{\gamma+\delta+3} d(\gamma,\delta)d(\gamma,\delta+1)d(\gamma,\delta+2)d(\gamma,\delta+3)\Big(1-d(\gamma,\delta+4)\Big)\Bigg) \end{align*} $$

Let's wrap this into a function and call it hazard:

Now we are ready to use these hazard rates and do MLE like in the two-period model. The sample comprises a cross section of spells $i\in\{1,\ldots,N\}$, some of which are completed at $\tau_i$, and some of which are incomplete lasting at least $T$ periods. Let $p_{\tau}(\gamma;\delta)$ denote the unconditional probability of individual $i$ with parameters $(\gamma,\delta)$ inventing for $\tau-1$ periods and stop inventing at $\tau$ if spell is complete and the unconditional probability of individual $i$ inventing for at least $\tau$ periods if spell is incomplete:

$$ p_{i}(\gamma;\delta) := \begin{cases} h_{\tau_i}(\gamma,\delta)\prod_{s=1}^{\tau_i-1}(1-h_s(\gamma,\delta)) &\text{ if spell is complete}\\ \prod_{s=1}^{T}(1-h_s(\gamma,\delta)) & \text{ if spell is incomplete} \end{cases} $$

The likelihood is then: $$\begin{align*} \mathcal{L}&=\prod_{i=1}^{N}p_{\tau_i}(\gamma;\delta)\\ \log\mathcal{L}&=\sum_{i=1}^{N}\log p_{\tau_i}(\gamma;\delta) \end{align*}$$

While we are playing with this model, we can think about this question: how much do our MLE estimates improve as i) N increases and ii) T increases in our data? If we have more information about what agents do in the future, can we estimate our parameter better? In order to see this, I will form the log-likelihood supposing that we have data up to $t=2,3,4,5$.

As $N$ grows, we see that our empirical hazard rates approach to our theory as they should. The table for estimation results show that i) holding constant the available information across time, the MLE estimates tend to the true value as the number of observations increase and ii) holding the number of observations constant, using more information on the agents choices across time helps efficiency. It is also interesting to see that using information up to $t=3$ does not have any improvement on the estimates compared to using information up to $t=2$. This is because no one quits at $t=3$; thus, there is no information to use for our estimation there.

Appendix: Sanity check for simulation for the infinite horizon model