# ECMT2130辅导、辅导R编程语言

1 ECMT2130 - 2022 semester 2, assignment 1

Your answers need to be submitted using the Canvas quiz for assignment 1. The R script and Microsoft Excel
spreadsheet produced in doing this assignment must be uploaded using this Canvas quiz. These documents
1. Portfolio optimisation
Use the data allocated to you to answer the following questions.
Throughout this assignment, all rates of return are simple monthly rates of return (not annualised),
expressed as a decimal rather than a percentage. Thus, for example, a rate of return of 5% would be
expressed in the data set as 0.05.
Unless otherwise stated: the investor can invest in all of the managed funds but cannot invest in the
risk-free asset; and the investor is fully invested.
Use the most recent value of the simple monthly risk-free rate of return as the “current risk-free rate of
return” when analysing the following portfolio optimisation problems.
Compute the excess rates of return for each fund, in each available time period. Add the current risk-free
rate of return to these excess rates of return for each fund to produce simple monthly rates of return
that do not incorporate risk-free rate of return variation as a source of risk.
Compute mean simple monthly rates of return on a fund using these adjusted simple monthly rates of
return (average over the entire available sample). If this is not clear, ask for clarification on Ed!
the funds’ rates of return. Again use the entire available sample.
(a) (2 points) Estimate the mean and the standard deviation of the simple monthly rate of return for
the Global Minimum Variance Portfolio (GMVP). Report the standard deviation as a percentage,
to 2 decimal places.
(b) (2 points) Estimate the mean and the standard deviation of the simple monthly rate of return for
the portfolio with minimum variance when shorting is allowed but no fund is allowed to have a
weight with an absolute value greater than 20%.
(c) (2 points) Estimate the mean and the standard deviation of the simple monthly rate of return for
the portfolio with minimum variance when no shorting is allowed and no fund can have a weight
above 20%.
(d) (2 points) Estimate the standard deviation of the simple monthly rate of return for the minimum
variance portfolio that has an expected simple monthly rate of return that is double that of the
GMVP.
(e) (2 points) Estimate the slope of the optimal Capital Allocation Line when the investor can invest
in the risk-free asset and faces no portfolio weight restrictions (other than the full investment
requirement). Use the current risk-free rate of return when solving this problem.
(f) (2 points) Estimate the mean and the standard deviation of the rate of return for the optimal
portfolio for an investor with expected utility described by the following equation:
E(U) = E(rp)? 2σ2p (1)
Assume that the investor can invest in all of the risky funds and in the risk-free asset and assume
that there are no constraints on their asset weights (aside from the full-investment requirement).
(g) (2 points) Using the asset weights for the optimal portfolio of the investor with expected utility
shown in equation 1, estimate the excess kurtosis of the portfolio’s simple monthly rate of return.
Use all of the available historical data to produce this estimate.
(h) (6 points) Critique the optimal portfolio weights found for the investor in part F, in terms of their
portfolio optimisation methodology. This part must be answered in no more than 300 words.
2 Assessment data
Each dataset is a numbered file that ends with the “.RData” suffix. Each file is an RData file, containing
the name and value for a number of R variables. You need to write an R script to load the variables from
the right dataset file and analyse the data stored in these variables.
All of the RData files are contained in the same ZIP file that is available on Canvas. Download that ZIP
file, extract its contents and then analyse the data in the RData file that is allocated to you. The number of
the data file that you have been allocated is listed beside your name in the assignment page on Canvas.
Download the zip file containing all of the possible data files and the starting point R script for the
assignment and extract the contents of the zip file into the folder where you want to do your work.
Your dataset contains 3 eXtensible Time Series (XTS) variables:
fundTotalReturnIndices
riskFreeRateOfReturn
markexTotalReturnIndex
Each of these variables contains monthly data relating to rates of return from the beginning of 2000, to
the end of 2021.
The total return index for the portfolio managed by each of different fund managers is contained in the
variable named fundTotalReturnIndices. The total return index for the fund manager “i” has column name:
v_i
The data for the monthly risk-free simple rate of return is stored in the riskFreeRateOfReturn variable
and its column name is:
r_i
The monthly data for the market total return index is stored in the markexTotalReturnIndex variable
and its column name is:
v_m
You can load the variables from your RData file by running the R function:
replacing “X” with the number of the data set that has been allocated to you.
Make sure that folder containing your data file and your R script is your working directory in R Studio.
Page 2
Evidence of work
Write an R script that uses the provided data to compute the data you want to export to Microsoft Excel
for portfolio optimisation. Note that you can make your own choices here. Use R or Excel, for example, to
estimate the relevant means, variances and covariances that you need to use to solve the portfolio optimisation
problems.
You can save data to a CSV file using the R command:
write.csv(variableName, "nameOfCSVFile.csv", sep=",")
The grid of data in the variable called “variableName” will be written out to the named CSV file with
commas separating each item in each row.
Load the data from the CSV file or files that you exported from R into an Excel workbook and then
solve each portfolio optimisation problem on a separate worksheet in that workbook. The use of a separate
worksheet for each problem is required so that markers can review the solver configurations for each problem.
If any solver configurations cannot be reviewed, you are unlikely to receive full marks for the associated
optimisation problem.