Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

FE 515 Midterm

The midterm contains two questions. Please solve these prob- lems in R and knit a pdf report. The report includes the question description, your solution and any comments if necessary.

Question 1: (50 points)

1.1 Download daily equity data of JPM and WFC (2012-01-01 to 2023-01- 01).

1.2 Calculate both the daily log return and weekly log return for each stock.

1.3 Visualize the distribution of these log returns using hist() function. Use par() function to put the four histogram together into one single graph, where each histogram is an individual subplot.

1.4 Calculate the first four moments, i.e.  mean, variance, skewness and kur- tosis, for each stock. Store the calculate result in a data frame and report the result in a table.

1.5 Draw a scatter plot of JPM daily return against WFC daily return.  (i.e. WFC return on x-axis and JPM return on y-axis)

1.6 Build a simple linear regression model using the WFC daily return as ex- planatory variable and the JPM daily return as response variable. Report the fitted model using summary( ) function.

1.7 Draw a regression line on the scatter plot using the fitted model above. Make sure use a different color to draw the regression line.

Question 2: (50 points)

2.1 Without using packages, create a function of 2 variables x” and ad- justed” that calculates the sample skewness of x” using the formulas on Lecture 6 page 20 and page 21. When adjusted” = TRUE, it returns the adjusted skewness of x”, and FALSE returns the unadjusted one.

2.2 Without using packages, create a function of 2 variables x” and ad- justed” that calculates the sample kurtosis of x” using the formulas on Lecture 6 page 20 and page 23. When adjusted” = TRUE, it returns the adjusted kurtosis of x”, and FALSE returns the unadjusted one.

2.3  Download historical price for ticker SPY” for the whole 2012 and 2013 years with quantmod package, use its adjusted close price to calculate daily log return (Note the adjusted close price is different from the adjusted” for sample moments).

2.4  Calculate the adjusted and unadjusted skewness for the daily log return in 2.3 using the function you defined.  (both numbers should be close to -0.15)

2.5  Calculate the adjusted and unadjusted kurtosis for the daily log return in

2.3 using the function you defined.  (both numbers should be close to 4.1)