x <- numeric(100)
x[1] <- 100
set.seed(123)
for (i in 2:100) {
x[i] <- x[i-1] + rnorm(1,1,1) - 0.009*i*rnorm(1,1,1)^2
}
x1 <- c(x[-1],0)
ret <- x1/x - 1
#arithmetic mean of net returns:
amean <- mean(ret[-100])*25000 ; amean
#arithmetic mean of log returns:
amean2 <- mean(diff(log(x)))*25000 ; amean2
#geometric mean of net returns:
gmean<- ((prod(1+ret[-100]))^(1/length(ret[-100]))-1)*25000; gmean
'amean' is pretty much nonsense. 'amean2' and 'gmean'
should be equivalent except one is a log return and the
other is a simple return. If you transform one return into
the other form, then you should get the same number.