1. Homepage
  2. Programming
  3. FINTECH 590 Risk Management Project Week03: Covariance Matrix, Nearest PSD, PCA

FINTECH 590 Risk Management Project Week03: Covariance Matrix, Nearest PSD, PCA

Engage in a Conversation
USDuke UniversityFINTECH 590Risk ManagementCovariance Matrix Nearest PSD PCAAdvanced Topics in Financial TechnologyPython

Project Week03

Instructions:

Be verbose. Explain clearly your reasoning, methods, and results in your written work. Write clear code that is well documented. With 99% certainty, you cannot write too many code comments. CourseNana.COM

Written answers are worth 8 points. Code is worth 2 points. 10 points total. CourseNana.COM

  1. When finished, respond to the questions in Sakai as “done.” We will record your grade there.
  2. In your code repository, create a folder called “Week03.”
  3. In that folder, include a. a PDF with your responses. b. All code c. A README file with instructions for us to run your code

Everything must be checked into your repository by 8am Saturday 2/11. A pull will be done at that time. Documents and code checked in after the instructors pull will not be graded. CourseNana.COM

You are welcome to use a notebook for coding, but do not rely on code to explain your answer. Use a document editor to write your responses and paste graphs into the document. Use words, math, tables, and charts to explain your results – not code. CourseNana.COM

This week we will implement the methodologies we discussed in class. These methodologies will be crucial for work later. CourseNana.COM

Some routines might be available in your programming language, but you need to implement them once to help your understanding. If you rely on a package, you need to prove that it works as expected in this homework. Implementation of these routines will aide in your understanding of the concepts and help you troubleshoot errors later. CourseNana.COM

You may find that your implementation is faster than your package, or that the package is faster. If you have proved that the package implementation is faster, and works as needed, you may use it throughout this class. CourseNana.COM

Data for problems can be found in CSV files with this document in the class repository. CourseNana.COM

Problem 1

Use the stock returns in DailyReturn.csv for this problem. DailyReturn.csv contains returns for 100 large US stocks and as well as the ETF, SPY which tracks the S&P500. CourseNana.COM

Create a routine for calculating an exponentially weighted covariance matrix. If you have a package that calculates it for you, verify that it calculates the values you expect. This means you still have to implement it. CourseNana.COM

Vary λ ∈ (0, 1). Use PCA and plot the cumulative variance explained by each eigenvalue for each λchosen. CourseNana.COM

What does this tell us about values of λ and the effect it has on the covariance matrix? CourseNana.COM

Problem 2

Copy the chol_psd(), and near_psd() functions from the course repository – implement in your programming language of choice. These are core functions you will need throughout the remainder of the class. CourseNana.COM

Implement Higham’s 2002 nearest psd correlation function. CourseNana.COM

Generate a non-psd correlation matrix that is 500x500. You can use the code I used in class: CourseNana.COM

n=500
sigma = fill(0.9,(n,n))
for i in 1:n
sigma[i,i]=1.0
end
sigma[1,2] = 0.7357
sigma[2,1] = 0.7357

Use near_psd() and Higham’s method to fix the matrix. Confirm the matrix is now PSD. CourseNana.COM

Compare the results of both using the Frobenius Norm. Compare the run time between the two. How does the run time of each function compare as N increases? CourseNana.COM

Based on the above, discuss the pros and cons of each method and when you would use each. There is no wrong answer here, I want you to think through this and tell me what you think. CourseNana.COM

Problem 3

Using DailyReturn.csv. CourseNana.COM

Implement a multivariate normal simulation that allows for simulation directly from a covariance matrix or using PCA with an optional parameter for % variance explained. If you have a library that can do these, you still need to implement it yourself for this homework and prove that it functions as expected. CourseNana.COM

Generate a correlation matrix and variance vector 2 ways: CourseNana.COM

  1. Standard Pearson correlation/variance (you do not need to reimplement the cor() and var() functions).
  2. Exponentially weighted λ = 0. 97

Combine these to form 4 different covariance matrices. (Pearson correlation + var()), Pearson correlation + EW variance, etc.) CourseNana.COM

Simulate 25,000 draws from each covariance matrix using: CourseNana.COM

  1. Direct Simulation
  2. PCA with 100% explained.
  3. PCA with 75% explained.
  4. PCA with 50% explained.

Calculate the covariance of the simulated values. Compare the simulated covariance to it’s input matrix using the Frobenius Norm (L2 norm, sum of the square of the difference between the matrices). Compare the run times for each simulation. CourseNana.COM

What can we say about the trade offs between time to run and accuracy. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
US代写,Duke University代写,FINTECH 590代写,Risk Management代写,Covariance Matrix代写, Nearest PSD代写, PCA代写,Advanced Topics in Financial Technology代写,Python代写,US代编,Duke University代编,FINTECH 590代编,Risk Management代编,Covariance Matrix代编, Nearest PSD代编, PCA代编,Advanced Topics in Financial Technology代编,Python代编,US代考,Duke University代考,FINTECH 590代考,Risk Management代考,Covariance Matrix代考, Nearest PSD代考, PCA代考,Advanced Topics in Financial Technology代考,Python代考,UShelp,Duke Universityhelp,FINTECH 590help,Risk Managementhelp,Covariance Matrixhelp, Nearest PSDhelp, PCAhelp,Advanced Topics in Financial Technologyhelp,Pythonhelp,US作业代写,Duke University作业代写,FINTECH 590作业代写,Risk Management作业代写,Covariance Matrix作业代写, Nearest PSD作业代写, PCA作业代写,Advanced Topics in Financial Technology作业代写,Python作业代写,US编程代写,Duke University编程代写,FINTECH 590编程代写,Risk Management编程代写,Covariance Matrix编程代写, Nearest PSD编程代写, PCA编程代写,Advanced Topics in Financial Technology编程代写,Python编程代写,USprogramming help,Duke Universityprogramming help,FINTECH 590programming help,Risk Managementprogramming help,Covariance Matrixprogramming help, Nearest PSDprogramming help, PCAprogramming help,Advanced Topics in Financial Technologyprogramming help,Pythonprogramming help,USassignment help,Duke Universityassignment help,FINTECH 590assignment help,Risk Managementassignment help,Covariance Matrixassignment help, Nearest PSDassignment help, PCAassignment help,Advanced Topics in Financial Technologyassignment help,Pythonassignment help,USsolution,Duke Universitysolution,FINTECH 590solution,Risk Managementsolution,Covariance Matrixsolution, Nearest PSDsolution, PCAsolution,Advanced Topics in Financial Technologysolution,Pythonsolution,