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:
\[ \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 \]
\[\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\).
An acceptable solution is to calculate the variance.
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}\).
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\).
# 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
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.