Docsity

Problem Set 1 - Fun with Distribution - Quantitative Analysis | POL 213, Assignments of Political Science

Toggle sidebar
bg1
POL 213: Problem Set 1
Fun With Distributions
Please answer the following questions. With your answer, please turn in
your Rlog-file. I am being intentionally vague on Rscript in this assignment in
hopes that you all can figure some of this out. It will be tough and I can answer
questions as need be.
1. Normal Distribution: The likelihood function for the normal distribution when
σ=1is given by:
L(θ|y) =
N
Y
=1
ƒ(y|μ, σ =1)
=
N
Y
=1
1
p2πexp −(y−μ)2
2(1)
In R, write a function that finds a value, μ, that maximizes the log-likelihood
of y, where yis a vector of ten observations drawn randomly from a standard
normal distribution. Generate 20 possible values for μand plot the resulting
log-likelihoods with respect to the μ. Label the graph axes appropriately. For
what value of μis the log-likelihood maximized? To verify your answer, solve
the first derivative. For this case, the first derivative is given by
∂
∂μ
−
N
X
=1
(y−μ)2
=2
N
X
=1
y−2Nμ. (2)
What value of μsatisfies the first order condition? In ordinary statistics, what
does μcorrespond to? (20 points)
2. Poisson Distribution: Suppose the likelihood function for the Poisson dis-
tribution is given by
L(θ|y) = e−NλλPy
Qy!.(3)
Note that the Poisson distribution is commonly used to describe the DGP for
variables of counts. For this problem, create a vector of 10 positive integers (0
is also ok). Keep the integers within the range [0,5]. First do a grid search and
find the value of λthat maximizes the function. Plot the likelihood with respect
to lambda. After inspecting this plot, redo your grid search using a finer mesh.
To help get you started, note that candidate values for λcan be generated by:
lambda <- seq(0,5, .01)
1
pf2

Partial preview of the text

Download Problem Set 1 - Fun with Distribution - Quantitative Analysis | POL 213 and more Assignments Political Science in PDF only on Docsity!

POL 213: Problem Set 1 Fun With Distributions

Please answer the following questions. With your answer, please turn in your R log-file. I am being intentionally vague on R script in this assignment in hopes that you all can figure some of this out. It will be tough and I can answer questions as need be.

  1. Normal Distribution: The likelihood function for the normal distribution when σ = 1 is given by:

L ( θ | y ) =

∏^ N

= 1

ƒ ( y | μ, σ = 1 )

∏^ N

= 1

p 2 π

exp

‚ −( y − μ )^2 2

Œ (1)

In R, write a function that finds a value, μ , that maximizes the log-likelihood of y , where y is a vector of ten observations drawn randomly from a standard normal distribution. Generate 20 possible values for μ and plot the resulting log-likelihoods with respect to the μ. Label the graph axes appropriately. For what value of μ is the log-likelihood maximized? To verify your answer, solve the first derivative. For this case, the first derivative is given by

∂ ∂μ

  −

∑^ N

= 1

( y − μ )^2

  (^) = 2

∑^ N

= 1

y − 2 Nμ. (2)

What value of μ satisfies the first order condition? In ordinary statistics, what does μ correspond to? (20 points)

  1. Poisson Distribution: Suppose the likelihood function for the Poisson dis- tribution is given by

L ( θ | y ) =

e − Nλλ

∑ y ∏ y!

Note that the Poisson distribution is commonly used to describe the DGP for variables of counts. For this problem, create a vector of 10 positive integers ( is also ok). Keep the integers within the range [0,5]. First do a grid search and find the value of λ that maximizes the function. Plot the likelihood with respect to lambda. After inspecting this plot, redo your grid search using a finer mesh. To help get you started, note that candidate values for λ can be generated by:

lambda <- seq(0,5, .01)

After this, you need to write the function given in equation 3 and plot it. The fine mesh grid can be constructed using the code fragment from above. De- scribe the location of the maximum in both plots and describe the differences you see between the first and second grid searches. (20 points)

  1. Using code given in lecture slides, estimate a logit model and show, us- ing the Hessian, what the standard errors of the regression coefficients should be. To do this, generate two vectors of data where the first vector is a binary sequence (1s, 0s) having 100 elements and the second vector is some random variable , defined however you want to define (i.e. it can be random if you want).(20 points)