留学生作业代写 Nonlinear econometrics for finance HOMEWORK 2 – cscodehelp代写
Nonlinear econometrics for finance HOMEWORK 2
Functions, minimization/maximization and GMM
This homework consists of a review of Matlab functions and minimiza- tion/maximization (Question 1). Matlab functions and minimization are then used (in Question 2) to estimate the consumption CAPM using GMM. You will use maximization in the next homework.
Instructions. For Question 1, you should only provide the Matlab code. For Question 2, you should provide two files: one with answers to all questions and one with your Matlab code. Please make sure that all codes can run properly.
Copyright By cscodehelp代写 加微信 cscodehelp
Problem 1. (30 points.) Use Matlab to answer the following questions. 1. (5 points.) Write a function in Matlab that takes as input a 2×1 vector
x = (x1, x2) and returns the value
y = x2 +3×2 +2x x1/2.
(Hint: You can find useful information about the definition of functions by clicking here: functions.)
2. (3 points.) Using Matlab, evaluate the value of the function in Question 1 when x = (1, 1). What if x = (3, 2)?
3. (5 points.) Write a code that finds the minimizer (x∗1,x∗2) and the minimum f(x∗1,x∗2) of the function in Question 1. (Hint: You should use the command fminsearch. You can find useful information about this command by clicking here: fminsearch.)
4. (5 points.) Now, write another function that takes 3 inputs: 1) a N × 1 vector of parameters θ, 2) a N ×1 vector x and 3) a N ×N matrix A. The output of the function is z = (x − θ)⊤A(x − θ), where the notation x⊤ is used to define the transpose of x. We want to minimize the function with respect to θ. Use fminsearch to find the vector θ that minimizes this function when the vector x and the matrix A are
T = 10000;
1 0 0 0 A=0 1 0 0.
(Hint: You should think of θ as a vector of variables while x,A is your “data”. You can add “data” in fminsearch by just adding inputs after options.)
5. (2 points.) Use fminsearch to find the vector θ that minimizes the same function when the vector x and the matrix A are
1 0.5 0.2 0.3 A=0.5 1 0.4 0.5.
0.2 0.4 1 0.2 0.3 0.5 0.2 1
6. (5 points.) Now, write a new function that takes 2 inputs: 1) a T × 1 vector x and 2) a scalar θ. The output of the function is
[xt log(θ) + (1 − xt) log(1 − θ)] . (1)
7. (5 points.) Generate the vector x using the following code in Matlab:
0 0 1 0
x = random(’Binomial’, 1, 0.3, 1, T)’;
Compute the value of θ that maximizes the function in Eq. (1) using fminsearch.
(Hint: You need to use the fact that
maxf(θ) = min(−f(θ)) θθ
In other words, computing the maximum of a function is equivalent to computing the minimum of the function with a minus sign in front of it.)
Problem 2. (70 points.) Consider, as we did in class, a representative investor who lives for two periods (t and t + 1) and has income et in period t and et+1 in period t + 1. The utility function of the representative investor is:
U(ct, ct+1) = u(ct) + βEt[u(ct+1)].
The investor can invest in an asset by buying θ shares at the unit price pt. The asset’s payoff xt+1 = pt+1 + dt+1 in the second period is uncertain. The investor chooses how many units (θ) of the asset to buy in order to maximize her/his utility function:
max u(ct) + βEt[u(ct+1)], θ
subject to the income/wealth constraints
ct+1 = et+1 + θxt+1.
1. (2 points.) Assume the investor has a CRRA utility:
c1−γ u(ct) = t .
Derive the economy’s pricing equations both in terms of prices and in terms of returns.
2. (2 points.) Use the return equation to derive estimable moment condi- tions.
3. (6 points.) Estimation. The file ccapmmonthlydata.xls contains
monthly data (not quarterly, as used in the sample GMM code on
OneDrive) on consumption growth and asset returns from February
1959 to November 1993. The first column contains the dates and the
second column contains the time series for consumption growth ct+1 .
Columns 3-12 are the asset returns for 10 assets.
Use the ccapmmonthlydata.xls data to estimate the parameters of the consumption CAPM using the GMM estimator. Let N denote the number of assets/portfolios and let d be the number of parameters to estimate.
(Hint: note that the data contains consumption growth ct+1 for t = ct
1, …, T and not consumption levels ct for t = 1, …, T . You should, therefore, modify accordingly the sample GMM code that I provided in order to calculate the moments correctly.)
Compute the first-stage GMM estimates of the d model parameters using the weight matrix WT = IN . (Do not be surprised to find a large value for gamma, i.e., a value much larger than what we saw in class.)
4. (10 points.) Estimation. Compute the second-stage estimates by re- estimating the parameters using the optimal weight matrix. Assume your data are i.i.d. The second-stage estimates should be used in all questions below. (Again, do not be surprised to find a large value for gamma, i.e., a value much larger than what we saw in class.)
5. (5 points.) Interpret your estimation results in economic terms. What do you learn about the representative investor?
6. (10 points.) Compute the asymptotic variance of the GMM estimator. Please note: the matrix Γ0 should be estimated without numerical differentiation (which is what the sample GMM code does). In other words, you should compute the gradient by hand.
7. (10 points.) Inference. Test whether β = 0.9.
8. (10 points.) Inference. Test whether γ = 4 and β = 0.9 jointly.
9. (10 points.) Inference. Test whether 50β = γ.
10. (5 points.) Inference. Test for over-identifying restrictions.
程序代写 CS代考 加微信: cscodehelp QQ: 2235208643 Email: firstname.lastname@example.org