# Excess returns and the portfolio's Sharpe ratio

You just learned how to create descriptive statistics of your portfolio returns. Now you will learn how to evaluate your portfolio's performance!

Performance evaluation involves comparing your investment choices with an alternative investment choice. Most often, the performance is compared with investing in an *(almost)* risk-free asset, such as the U.S. Treasury Bill. The return from a U.S. Treasury Bill is known as a risk-free rate because Treasury Bills (T-Bills) are backed by the U.S. Government.

In this exercise, you will be asked to annualize the risk-free rate by using the compound interest formula. The yearly **compounded interest** rate is given by *\((1+y)^{12}-1\)*. The annual rate is used to estimate a yearly return and is very useful for forecasting.

As you might recall from the video, the **Sharpe Ratio** is an important metric that tells us the return-to-volatility ratio. It is calculated by taking the *mean of excess returns (returns - risk-free rate), divided by the volatility of the returns*.

Pre-loaded in your workspace is the object `rf`

which contains the one-month rate of a T-Bill. The S&P 500 portfolio returns are still available as `sp500_returns`

.

This is a part of the course

## “Introduction to Portfolio Analysis in R”

### Exercise instructions

- Calculate the annualized risk-free rate using the compound interest formula, assign it to
`annualized_rf`

. - Plot the time-series of
`annualized_rf`

using`plot.zoo()`

. - Calculate the excess monthly portfolio return, assign it to
`sp500_excess`

. - Print the mean excess returns and the mean returns. Compare the two.
- Complete the code to calculate the monthly Sharpe ratio, assign it to
`sp500_sharpe`

.

### Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

```
# Compute the annualized risk free rate
annualized_rf <- (1 + ___)^__ - ___
# Plot the annualized risk-free rate
# Compute the series of excess portfolio returns
sp500_excess <- ___ - ___
# Compare the mean of sp500_excess and sp500_returns
mean(___)
mean(___)
# Compute the Sharpe ratio
sp500_sharpe <- ___(sp500_excess) / ___(sp500_returns)
```

This exercise is part of the course

## Introduction to Portfolio Analysis in R

Apply your finance and R skills to backtest, analyze, and optimize financial portfolios.

The history of portfolio returns reveals valuable information about how much the investor can expect to gain or lose. This chapter introduces the R functionality to analyze the investment performance based on a statistical analysis of the portfolio returns. It includes graphical analysis and the calculation of performance statistics expressing average return, risk, and risk-adjusted return over rolling estimation samples.

Exercise 1: Dimensions of portfolio performanceExercise 2: Exploring the monthly S&P 500 returnsExercise 3: The monthly mean and volatilityExercise 4: The (annualized) Sharpe ratioExercise 5: Excess returns and the portfolio's Sharpe ratioExercise 6: Annualized mean and volatilityExercise 7: Time-variation in portfolio performanceExercise 8: Effect of window length choiceExercise 9: Rolling annualized mean and volatilityExercise 10: Subperiod performance analysis and the function windowExercise 11: Non-normality of the return distributionExercise 12: Balancing risk and rewardExercise 13: Detecting non-normality using skewness and kurtosisExercise 14: Downside risk measuresExercise 15: Drawdowns due to buying high, selling low### What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.