Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 271

Example: Whichmeanmakes most sense?

Оглавление

What is the average return when you know that the share price had the following returns: −50%, +50%,−50%, +50%. Try the arithmetic mean and the mean of the log-returns.

returns <- c(0.5,-0.5,0.5,-0.5) # Arithmetic mean: aritmean <- mean(returns) # The ln-mean: log_returns <- returns for(k in 1:length(returns)) { log_returns[k] <- log( returns[k] + 1) } logmean <- mean(log_returns) exp(logmean) - 1 ## [1] -0.1339746 # What is the value of the investment after these returns: V_0 <- 1 V_T <- V_0 for(k in 1:length(returns)) { V_T <- V_T * (returns[k] + 1) } V_T ## [1] 0.5625 # Compare this to our predictions: ## mean of log-returns V_0 * (exp(logmean) - 1) ## [1] -0.1339746 ## mean of returns V_0 * (aritmean + 1) ## [1] 1

The Big R-Book

Подняться наверх