# Quiz 7 (15 minutes)

Suppose that you observe an IID random sample $$\{X_t\}_{t=1}^n$$ of size $$n=5$$ from $$\mathsf{Unif}\left[1,\alpha\right]$$, where $$\alpha\in\mathbb{R}$$ and $$\alpha>1$$.

Below you will find an observed sample of size $$n=5$$:

## [1] 2.41 2.27 1.28 1.75 1.90

Answer the following questions given the information above:

• Provide two moment conditions which will allow you to estimate $$\alpha$$.
• Provide two estimates of $$\alpha$$ given the observed sample and the moment conditions you provided.

# Suggested solution

• Two possible moment conditions which will allow estimation of $$\alpha$$ are:

$\begin{eqnarray} \mathbb{E}\left(X_t-\frac{1+\alpha}{2}\right) &=& 0 \\ \mathbb{E}\left(X_t^2-\frac{\alpha^2+\alpha+1}{3}\right) &=& 0 \end{eqnarray}$

To show that these two moment conditions hold, you have to calculate

$\mathbb{E}\left(X_t\right)=\int_1^{\alpha} t \cdot \frac{1}{\alpha-1} \,\,dt \qquad \mathbb{E}\left(X_t^2\right)=\int_1^{\alpha} t^2 \cdot \frac{1}{\alpha-1} \,\,dt$

# Suggested solution, continued

• An estimator based on the moment condition $\mathbb{E}\left(X_t-\frac{1+\alpha}{2}\right)=0$ involves solving for $$\widehat{\alpha}$$ in the equation

$\frac{1}{n}\sum_{t=1}^n X_t - \frac{1+\widehat{\alpha}}{2}=0.$

An estimate of $$\alpha$$ based on the data is $$2*(1.922)-1=2.844$$.

# Suggested solution, continued

• An estimator based on the moment condition $\mathbb{E}\left(X_t^2-\frac{\alpha^2+\alpha+1}{3}\right)=0$ involves solving for $$\widetilde{\alpha}$$ in the equation $\frac{1}{n}\sum_{t=1}^n X_t^2-\frac{\widetilde{\alpha}^2+\widetilde{\alpha}+1}{3}=0.$ Here we need solve a quadratic equation in $$\widetilde{\alpha}$$, which is $$\widetilde{\alpha}^2+\widetilde{\alpha}+1-3*(3.85438)=0$$. The two roots of the quadratic equation based on the data are $$2.788$$ and $$-3.788$$. Choose $$\widetilde{\alpha}=2.788$$.

# Remarks on submitted solutions

• An acceptable solution is to calculate the variance.

• But this may take more time, especially when calculating an estimate.
• Another issue is that it is incorrect to write $\mathbb{E}\left(X_t\right) = \frac{1}{n}\sum_{t=1}^n X_t$

• One thing to note is that it is very likely that $$\widehat{\alpha}\neq \widetilde{\alpha}$$.

# Implementing GMM

• Try writing down a GMM criterion function which exploits both moments. You can use a weighting matrix equal to the identity matrix.

• In the next slide, you will see a very simple R program to implement one version of GMM.

• The data used in the quiz was from $$\mathsf{Unif}\left[1,3\right]$$. In this context, $$\beta^o = 3$$.

# GMM, R version

# Create GMM criterion function
# Weighting matrix is identity matrix
gmm.obj <- function(alpha)
{
# Draw random numbers from uniform
x <- runif(5, 1, 3)
# Setup the GMM objective function
return((sum(x)-(1+alpha)/2)^2+(sum(x^2)-(alpha^2+alpha+1)/3)^2)
}
# Command to find minimizers/maximizers
# Valid for one-dimensional problems only
# Minimize is the default
# c(1, 100) is the interval [1,100]. This is to tell
# optimize where to search for a minimizer.
optimize(gmm.obj, c(1,100))
## $minimum ## [1] 8.46 ## ##$objective
## [1] 102
# $minimum is the minimizer #$objective is the smallest value of the objective function

# GMM, R version, continued

• Try adjusting the interval $$[1,100]$$ to $$[1,4]$$ or $$[1,5]$$, or some other interval. Check how sensitive the results are to the choice of where to look for a minimizer.

• Try increasing the number of observations from $$n=5$$ to $$n=200$$ for example.

• Adjust the code to use a weighting matrix of the form $\left(\begin{array}{cc} 1 & 0\\ 0 & 4 \end{array}\right)$

• What do you notice? Try adjusting the interval where you look for a minimizer.