Page 1 of 1

Statistics question

Posted: Tue Oct 08, 2019 12:54 pm
by Kelly
Is it possible to work out what the expected return would be at the 1st and 5th percentile for a portfolio with an expected return and standard deviation of 5.8% and 11.4%? I'd like to calculate those returns expected in 5 and 10 years.

Thankyou
Kelly

Re: Statistics question

Posted: Tue Oct 08, 2019 1:06 pm
by 305pelusa
If I understand correctly, you want to know what the worst 1% and 5% returns could be given a mean return of 5.8% and St Dev 11.4%?

If so, you could grab a normal distribution calculator like
http://onlinestatbook.com/2/calculators ... _dist.html

And calculate the "below" value of different bad returns (say -18) and then see how much area is under the curve. You want to find the negative return that produces an area under the curve below it of 0.01 and 0.05. It looks like -20% and -13% do that respectively.

Hopefully that's what you wanted to know.

Re: Statistics question

Posted: Tue Oct 08, 2019 1:14 pm
by HootingSloth
Kelly wrote:
Tue Oct 08, 2019 12:54 pm
Is it possible to work out what the expected return would be at the 1st and 5th percentile for a portfolio with an expected return and standard deviation of 5.8% and 11.4%? I'd like to calculate those returns expected in 5 and 10 years.

Thankyou
Kelly
Assuming that the expected return and standard deviation are for annual returns (rather than the whole period), I think you would want to use a parameterized Monte Carlo calculator to do this. Portfolio Visualizer has a highly customizable calculator. Here is what I would do to answer your question: https://www.portfoliovisualizer.com/mon ... nt=1000000

Re: Statistics question

Posted: Tue Oct 08, 2019 1:18 pm
by Kelly
305pelusa wrote:
Tue Oct 08, 2019 1:06 pm
If I understand correctly, you want to know what the worst 1% and 5% returns could be given a mean return of 5.8% and St Dev 11.4%?

If so, you could grab a normal distribution calculator like
http://onlinestatbook.com/2/calculators ... _dist.html

And calculate the "below" value of different bad returns (say -18) and then see how much area is under the curve. You want to find the negative return that produces an area under the curve below it of 0.01 and 0.05. It looks like -20% and -13% do that respectively.

Hopefully that's what you wanted to know.
Thank you. No surprise an MIT alum would know of this website. I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.

If I enter below -9.5, the calculator returns an "Area (probability) = .05". Is that the return expected at the 5th percentile?

Thankyou!

Re: Statistics question

Posted: Tue Oct 08, 2019 1:18 pm
by 305pelusa
Kelly wrote:
Tue Oct 08, 2019 12:54 pm
Is it possible to work out what the expected return would be at the 1st and 5th percentile for a portfolio with an expected return and standard deviation of 5.8% and 11.4%? I'd like to calculate those returns expected in 5 and 10 years.

Thankyou
Kelly
Oh if it's over 5 or 10 years, you could also use a normal distribution calculator that takes a sample size as input as well. You could then figure out the lowest mean return of that sample of 5 or 10 years at a 1% or 5% worst case scenario. Then you'd convert that mean sample return into a CAGR (CAGR = Mean - 1/St Dev^2 or something like that).

Re: Statistics question

Posted: Tue Oct 08, 2019 1:23 pm
by 305pelusa
Kelly wrote:
Tue Oct 08, 2019 1:18 pm
305pelusa wrote:
Tue Oct 08, 2019 1:06 pm
If I understand correctly, you want to know what the worst 1% and 5% returns could be given a mean return of 5.8% and St Dev 11.4%?

If so, you could grab a normal distribution calculator like
http://onlinestatbook.com/2/calculators ... _dist.html

And calculate the "below" value of different bad returns (say -18) and then see how much area is under the curve. You want to find the negative return that produces an area under the curve below it of 0.01 and 0.05. It looks like -20% and -13% do that respectively.

Hopefully that's what you wanted to know.
Thank you. No surprise an MIT alum would know of this website. I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.

If I enter below -9.5, the calculator returns an "Area (probability) = .05". Is that the return expected at the 5th percentile?

Thankyou!
For a mean of 5.8, St Dev of 11.4, I'm finding -9.5 gives me an area of 0.089. Are you sure you put in the right mean and St Dev?

Remember this will only tell you the likelihood for 1 year. If you're looking for 5 or 10 years, you'll have to use a calculator that takes into account sample size.
https://mathcracker.com/normal-probabil ... tributions

You should find a given mean and CAGR return is much more unlikely as you increase the sample size

Re: Statistics question

Posted: Tue Oct 08, 2019 1:28 pm
by Doc
Kelly wrote:
Tue Oct 08, 2019 1:18 pm
I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.
You could have done worse. You could have been at the other end of Mass Ave. :twisted:

Re: Statistics question

Posted: Tue Oct 08, 2019 1:42 pm
by cheezit
Nb. monthly equity returns are not normally distributed and in fact looking backwards do not appear to have followed any known distribution; the PV monte carlo sim has some knobs to turn to account for some aspects of the non-normality observed in historic US equity returns, as do some others.

If you look at yearly returns, things look more normal but the sample size isn't large enough to have confidence that the tails aren't really fatter than a normal distribution with appropriate parameters would predict.

Re: Statistics question

Posted: Tue Oct 08, 2019 1:43 pm
by Kelly
Mathcracker: with a mean of 5.3, std dev of 9, sample of 5 I get a Pr of 0.089 of having a return equal/less than -0.11.

Portfolio visualizer shows a 10th percentile, 5 year return of -0.11.

Mathcracker reports Pr 0.01 for a return less than -4 (1st percentile)
Pr 0.058 for a return less than -1 (5th percentile)

So mathcracker seems to have what I'm after.

Thanks very much!

Re: Statistics question

Posted: Tue Oct 08, 2019 2:07 pm
by Kelly
cheezit wrote:
Tue Oct 08, 2019 1:42 pm
Nb. monthly equity returns are not normally distributed and in fact looking backwards do not appear to have followed any known distribution; the PV monte carlo sim has some knobs to turn to account for some aspects of the non-normality observed in historic US equity returns, as do some others.

If you look at yearly returns, things look more normal but the sample size isn't large enough to have confidence that the tails aren't really fatter than a normal distribution with appropriate parameters would predict.
Agreed. I use financial planning software that uses a normal distribution but doesn't report below the 10th percentile. My question was how it's MC returns compared to historical worst returns. It's tenth percentile returns for five years works out to -0.10 NOMINAL CAGR . The five year REAL return for 60/40 from Dec '68 through Nov '73 was -3.37. That period starts the worst 30 year retirement period observed.

Once I add inflation is it fair to say that the MC worst case is as bad as the historic?

Re: Statistics question

Posted: Tue Oct 08, 2019 2:08 pm
by Kelly
Doc wrote:
Tue Oct 08, 2019 1:28 pm
Kelly wrote:
Tue Oct 08, 2019 1:18 pm
I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.
You could have done worse. You could have been at the other end of Mass Ave. :twisted:
Ha! NU IS at the wrong end of mass ave!

Re: Statistics question

Posted: Tue Oct 08, 2019 2:27 pm
by Doc
Kelly wrote:
Tue Oct 08, 2019 2:08 pm
Doc wrote:
Tue Oct 08, 2019 1:28 pm
Kelly wrote:
Tue Oct 08, 2019 1:18 pm
I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.
You could have done worse. You could have been at the other end of Mass Ave. :twisted:
Ha! NU IS at the wrong end of mass ave!
You're OK. I didn't think that NU was even in the same city let alone on the same street. I was thinking of a little school called Havad or something like that. :wink:

Re: Statistics question

Posted: Wed Oct 09, 2019 9:10 am
by patrick013
Wondering what the frequency distribution of returns looks like graphically. The confidence interval of the larger side would be more reliable than the confidence interval of the smaller side. Not a normal distribution so subjectively 1.5 x SD for the smaller side ? Those big drawdowns will happen but with small frequency. A different stat in itself.

Re: Statistics question

Posted: Wed Oct 09, 2019 10:06 am
by Taylor Larimore
Kelly wrote:
Tue Oct 08, 2019 12:54 pm
Is it possible to work out what the expected return would be at the 1st and 5th percentile for a portfolio with an expected return and standard deviation of 5.8% and 11.4%? I'd like to calculate those returns expected in 5 and 10 years.

Thankyou
Kelly
Kelly:

During my investing life (69 years), I have learned that statistics (nearly always based on past performance) are almost useless to forecast "expected return" for stocks and bonds. Statistics are not going to tell you the stock and bond returns tomorrow, next week, next month or next year. Statistics are useful for many things, but not "expected return."


"There are three kinds of lies: lies, damned lies, and statistics." -- Benjamin Disraeli, British Prime Minister

Best wishes.
Taylor
Jack Bogle's Words of Wisdom (about forecasts): "Nobody knows nothing."

Re: Statistics question

Posted: Wed Oct 09, 2019 10:12 am
by willthrill81
Kelly wrote:
Tue Oct 08, 2019 2:07 pm
cheezit wrote:
Tue Oct 08, 2019 1:42 pm
Nb. monthly equity returns are not normally distributed and in fact looking backwards do not appear to have followed any known distribution; the PV monte carlo sim has some knobs to turn to account for some aspects of the non-normality observed in historic US equity returns, as do some others.

If you look at yearly returns, things look more normal but the sample size isn't large enough to have confidence that the tails aren't really fatter than a normal distribution with appropriate parameters would predict.
Agreed. I use financial planning software that uses a normal distribution but doesn't report below the 10th percentile. My question was how it's MC returns compared to historical worst returns. It's tenth percentile returns for five years works out to -0.10 NOMINAL CAGR . The five year REAL return for 60/40 from Dec '68 through Nov '73 was -3.37. That period starts the worst 30 year retirement period observed.

Once I add inflation is it fair to say that the MC worst case is as bad as the historic?
MC analyses are known to produce significantly worse 'worst' cases than occurred in history because they fail to incorporate any type of mean reversion. Derek Tharp noted this a couple of years ago in this post on Michael Kitces' website. For instance, a 'standard' MC analysis assumes that a 50% drop in stocks is just as likely to occur before stocks drop 50% as before, which is extremely illogical; it's widely agreed that the expected return of stocks after a 50% drop is much higher than the expected return before the 50% drop. Consequently, many of the MC generated scenarios look downright apocalyptic (e.g. Great Depression part 2 followed by 1970s stagflation followed by the popping of the tech bubble, etc.), something that could very well make the entire financial system implode.

Annual returns in stocks may not come from a normal distribution, and they are definitely not independent of each other, both of which are assumptions for most statistical tools. Hence, using only the mean and std. dev. in a predictive manner, at least with tools that have these assumptions, is likely to lead to very erroneous results, never mind the fact that we don't know a priori what the mean and std. dev. will be in the future.

There are ways to address this shortfall, but it's difficult to do with 'synthetic' data, as you apparently wish to do.

Re: Statistics question

Posted: Wed Oct 09, 2019 10:29 am
by birnhamwood
I was given Bs in all my statistics courses.

Re: Statistics question

Posted: Wed Oct 09, 2019 10:43 am
by willthrill81
birnhamwood wrote:
Wed Oct 09, 2019 10:29 am
I was given Bs in all my statistics courses.
Were you 'given' Bs or is that what you earned? :wink:

Re: Statistics question

Posted: Wed Oct 09, 2019 1:22 pm
by MathIsMyWayr
Doc wrote:
Tue Oct 08, 2019 2:27 pm
Kelly wrote:
Tue Oct 08, 2019 2:08 pm
Doc wrote:
Tue Oct 08, 2019 1:28 pm
Kelly wrote:
Tue Oct 08, 2019 1:18 pm
I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.
You could have done worse. You could have been at the other end of Mass Ave. :twisted:
Ha! NU IS at the wrong end of mass ave!
You're OK. I didn't think that NU was even in the same city let alone on the same street. I was thinking of a little school called Havad or something like that. :wink:
Not quite. One is in the Hub and the other one is in Our fair city.

Re: Statistics question

Posted: Wed Oct 09, 2019 1:45 pm
by MathIsMyWayr
The crux of a normal distribution is the central limit theorem. Since you take a rather small number of samples from a set which does not have a normal distribution, how can you get other estimates with a high degree of confidence.

Re: Statistics question

Posted: Wed Oct 09, 2019 2:12 pm
by JupiterJones
Kelly wrote:
Tue Oct 08, 2019 2:08 pm
Doc wrote:
Tue Oct 08, 2019 1:28 pm
Kelly wrote:
Tue Oct 08, 2019 1:18 pm
I was on the other side of the river at Northeastern where I did well in stats but that was 30 yrs ago.
You could have done worse. You could have been at the other end of Mass Ave. :twisted:
Ha! NU IS at the wrong end of mass ave!
Well I went to school (briefly) on Mass Ave between MIT and NU. I don't think stats was even offered as an elective, so what do I know? :D

That said... I seem to recall reading somewhere that stock returns are not normally distributed. If so, I would caution reading too much into standard deviation here as any other than a general "relative risk" metric to be used where comparing funds.

Re: Statistics question

Posted: Wed Oct 09, 2019 2:24 pm
by 305pelusa
MathIsMyWayr wrote:
Wed Oct 09, 2019 1:45 pm
The crux of a normal distribution is the central limit theorem. Since you take a rather small number of samples from a set which does not have a normal distribution, how can you get other estimates with a high degree of confidence.
This is true but it's important to ask what returns are not normally distributed.
It is stock market daily returns that have been shown to not be normally distributed (strongly so). But that means that if you're looking at 10 years of returns, it's more like 2500 samples. So the CLT can be applied to say, approximately, that the stock market decade returns are normally distributed.

Re: Statistics question

Posted: Wed Oct 09, 2019 2:34 pm
by hdas
305pelusa wrote:
Wed Oct 09, 2019 2:24 pm
But that means that if you're looking at 10 years of returns, it's more like 2500 samples.
[OT comment removed by admin LadyGeek] care to control the overlapping problem? Cheers :greedy

Re: Statistics question

Posted: Wed Oct 09, 2019 2:50 pm
by 305pelusa
hdas wrote:
Wed Oct 09, 2019 2:34 pm
305pelusa wrote:
Wed Oct 09, 2019 2:24 pm
But that means that if you're looking at 10 years of returns, it's more like 2500 samples.
[OT comment removed by admin LadyGeek] care to control the overlapping problem? Cheers :greedy
There's no overlap, I'm not talking about rolling returns.

I'm saying the average decade returns of the following decade will be equal to 2500 times the average of the following 2500 daily returns. The daily returns aren't normal but their average is. And 2500 times the average is too. So the upcoming average decade return should be approximately distributed (to the extent that 2500 samples is enough for the CLT).

If you wanted to show the above in practice with past data, you'll want to use independent decades like you said of course :)

Re: Statistics question

Posted: Wed Oct 09, 2019 3:46 pm
by MathIsMyWayr
305pelusa wrote:
Wed Oct 09, 2019 2:50 pm
hdas wrote:
Wed Oct 09, 2019 2:34 pm
305pelusa wrote:
Wed Oct 09, 2019 2:24 pm
But that means that if you're looking at 10 years of returns, it's more like 2500 samples.
[OT comment removed by admin LadyGeek] care to control the overlapping problem? Cheers :greedy
There's no overlap, I'm not talking about rolling returns.

I'm saying the average decade returns of the following decade will be equal to 2500 times the average of the following 2500 daily returns. The daily returns aren't normal but their average is. And 2500 times the average is too. So the upcoming average decade return should be approximately distributed (to the extent that 2500 samples is enough for the CLT).

If you wanted to show the above in practice with past data, you'll want to use independent decades like you said of course :)
"the average decade returns of the following decade will be equal to 2500 times the average of the following 2500 daily return" - yes, if geometric mean, not algebraic mean.
A problem with "2500" samples is that the actual number is not quite large as 2500, but may be much less because of the strong correlation among them. They are not really random, but there is strong correlation. The problem is that the correlation is not predictable.

Re: Statistics question

Posted: Wed Oct 09, 2019 4:14 pm
by 305pelusa
MathIsMyWayr wrote:
Wed Oct 09, 2019 3:46 pm
305pelusa wrote:
Wed Oct 09, 2019 2:50 pm
hdas wrote:
Wed Oct 09, 2019 2:34 pm
305pelusa wrote:
Wed Oct 09, 2019 2:24 pm
But that means that if you're looking at 10 years of returns, it's more like 2500 samples.
[OT comment removed by admin LadyGeek] care to control the overlapping problem? Cheers :greedy
There's no overlap, I'm not talking about rolling returns.

I'm saying the average decade returns of the following decade will be equal to 2500 times the average of the following 2500 daily returns. The daily returns aren't normal but their average is. And 2500 times the average is too. So the upcoming average decade return should be approximately distributed (to the extent that 2500 samples is enough for the CLT).

If you wanted to show the above in practice with past data, you'll want to use independent decades like you said of course :)
"the average decade returns of the following decade will be equal to 2500 times the average of the following 2500 daily return" - yes, if geometric mean, not algebraic mean.
A problem with "2500" samples is that the actual number is not quite large as 2500, but may be much less because of the strong correlation among them. They are not really random, but there is strong correlation. The problem is that the correlation is not predictable.
^I'm talking about arithmetic mean above exclusively. One can then convert to geometric via an approximation with St Dev. I'm not sure what an algebraic mean is.

Your point about correlation and dependency is a good one. As well as many other shortcomings of the approach. So don't use the above as gospel and purely as very rough/crude approximations. Then again I think that's something we ALL know so I don't think it bears repeating.

Re: Statistics question

Posted: Wed Oct 09, 2019 7:23 pm
by Small Savanna
I tried simulating this in R, with 100,000 trials. I’m getting a 28% loss after 10 years in the 1st percentile and a 7% loss in the 5th percentile. I know there are people on this forum who code for a living, so would welcome anybody who would like to check my work. Here is the code:

# Inputs
n <- 100000
years <- 10
meany <- 0.058
standy <- 0.114
x <- rep(1,n) # Vector of length n
# do n trials of duration years
for (i in 1:years){
x <- x * (1 + rnorm(n,meany,standy))
}
# check
mean(x)
(1+meany)^years
ordered <- sort(x)
# 1st percentile
ordered[n/100]
# 5th percentile
ordered[n/20]

Re: Statistics question

Posted: Wed Oct 09, 2019 8:15 pm
by abuss368
Kelly wrote:
Tue Oct 08, 2019 12:54 pm
Is it possible to work out what the expected return would be at the 1st and 5th percentile for a portfolio with an expected return and standard deviation of 5.8% and 11.4%? I'd like to calculate those returns expected in 5 and 10 years.

Thankyou
Kelly
I have learned much over the years from investing. One of which is to not rely on past performance (which statistics is usually based on).

Re: Statistics question

Posted: Wed Oct 09, 2019 8:46 pm
by 305pelusa
Small Savanna wrote:
Wed Oct 09, 2019 7:23 pm
I tried simulating this in R, with 100,000 trials. I’m getting a 28% loss after 10 years in the 1st percentile and a 7% loss in the 5th percentile. I know there are people on this forum who code for a living, so would welcome anybody who would like to check my work. Here is the code:

# Inputs
n <- 100000
years <- 10
meany <- 0.058
standy <- 0.114
x <- rep(1,n) # Vector of length n
# do n trials of duration years
for (i in 1:years){
x <- x * (1 + rnorm(n,meany,standy))
}
# check
mean(x)
(1+meany)^years
ordered <- sort(x)
# 1st percentile
ordered[n/100]
# 5th percentile
ordered[n/20]
28% loss is approximately an average yearly return of -2.6%. That sounds about right. I've never used R but you code seems ok.

Re: Statistics question

Posted: Thu Oct 10, 2019 6:50 am
by GrowthSeeker
Kelly wrote:
Tue Oct 08, 2019 12:54 pm
Is it possible to work out what the expected return would be at the 1st and 5th percentile for a portfolio with an expected return and standard deviation of 5.8% and 11.4%? I'd like to calculate those returns expected in 5 and 10 years.

Thankyou
Kelly
The giant assumption is that portfolio returns act as if they are random variables whose distribution is a Normal distribution. The second giant assumption is that each year's investment result is independent of every other year's result. Since neither of these is true, the following mathematical discussion can almost surely be taken with a grain of salt.
But, here goes:

So if the mean of the ROI is 5.8 percent, then to get next year's balance you would multiply by 1.058; you have to add a one to the percentage return to get the multiplication factor.
And if the standard deviation is 11.4 percent, then the variance is the square of 0.114 which is 0.012996.

If this process repeats for N years, it is like we are multiplying N random numbers together, each with the same mean and s.d.

See the wikipedia page on probability function when multiplying random numbers.

For the mean: "When two random variables are statistically independent, the expectation of their product is the product of their expectations."
So the expected value for the mean is 1.058^N. And to get the ROI from that, just subtract 1.

For the standard deviation, the relevant section is "Variance of the product of independent random variables"
To get the variance of the product of several random variables, for each variable, add the variance to the square of the mean. Now multiply all those together. That is the first term of the equation. Next take just the square of the mean for each variable; and multiply all those together. That is the second term. Now subtract the second term from the first term. Now you have the variance of the product of those random variables. Next take the square root: and you have the standard deviation.
In our case:
sqrt{(0.012996 + 1.119364)^N - 1.119364^N }

Code: Select all

N    mean     var      sd   % ROI   sd(%)
1    1.058   0.013   0.114   5.8%    11.4%
5    1.326   0.104   0.323   32.6%   32.3%
10   1.757   0.378   0.615   75.7%   61.6%

Re: Statistics question

Posted: Thu Oct 10, 2019 7:05 am
by goflyers13
Small Savanna wrote:
Wed Oct 09, 2019 7:23 pm
I tried simulating this in R, with 100,000 trials. I’m getting a 28% loss after 10 years in the 1st percentile and a 7% loss in the 5th percentile. I know there are people on this forum who code for a living, so would welcome anybody who would like to check my work. Here is the code:

# Inputs
n <- 100000
years <- 10
meany <- 0.058
standy <- 0.114
x <- rep(1,n) # Vector of length n
# do n trials of duration years
for (i in 1:years){
x <- x * (1 + rnorm(n,meany,standy))
}
# check
mean(x)
(1+meany)^years
ordered <- sort(x)
# 1st percentile
ordered[n/100]
# 5th percentile
ordered[n/20]
I did the same thing in MATLAB and got the same results. For a 5-year simulation, the 1st percentile is -29%, and the 5th percentile is -15%. See code below:

% Define normal distribution parameters
mu = 0.058;
sigma = 0.114;

% Define sample size for Monte-Carlo simulation
sample_size = 100000;

% Define simulation length in years
years = 10;

% Define initial portfolio value
initial_value = 1;

% Define initial portfolio value for all samples in the simulation
portfolio_value = initial_value*ones(sample_size, 1);

% Loop for each year
for i = 1:years
% Randomly sample annual return from normal distribution for each
% sample in the Monte-Carlo simulation
annual_return = normrnd(mu, sigma, [sample_size, 1]);

% Calculate portfolio value
portfolio_value = (1+annual_return).*portfolio_value;
end

% Calculate total return as a percentage
total_return = 100*(portfolio_value-initial_value)/initial_value;

% Calculate 1st and 5th percentiles of total return
percentile_1 = prctile(total_return, 1);
percentile_5 = prctile(total_return, 5);

Re: Statistics question

Posted: Thu Oct 10, 2019 10:30 am
by an_asker
willthrill81 wrote:
Wed Oct 09, 2019 10:43 am
birnhamwood wrote:
Wed Oct 09, 2019 10:29 am
I was given Bs in all my statistics courses.
Were you 'given' Bs or is that what you earned? :wink:
Maybe (s)he meant to capitalize the "S" ;-)

Re: Statistics question

Posted: Thu Oct 10, 2019 11:26 am
by 305pelusa
an_asker wrote:
Thu Oct 10, 2019 10:30 am
willthrill81 wrote:
Wed Oct 09, 2019 10:43 am
birnhamwood wrote:
Wed Oct 09, 2019 10:29 am
I was given Bs in all my statistics courses.
Were you 'given' Bs or is that what you earned? :wink:
Maybe (s)he meant to capitalize the "S" ;-)
At first I was like "I don't think statistics is capitalized?".

I surprise myself with my own stupidity some times

Re: Statistics question

Posted: Thu Oct 10, 2019 12:35 pm
by an_asker
305pelusa wrote:
Thu Oct 10, 2019 11:26 am
an_asker wrote:
Thu Oct 10, 2019 10:30 am
willthrill81 wrote:
Wed Oct 09, 2019 10:43 am
birnhamwood wrote:
Wed Oct 09, 2019 10:29 am
I was given Bs in all my statistics courses.
Were you 'given' Bs or is that what you earned? :wink:
Maybe (s)he meant to capitalize the "S" ;-)
At first I was like "I don't think statistics is capitalized?".

I surprise myself with my own stupidity some times
I don't think it is you - I have to explain my PJ multiple times ... such as the one I made about folks not recognizing climate change as being "person non Greta"! ;-)

Re: Statistics question

Posted: Thu Oct 17, 2019 5:13 pm
by JupiterJones
Small Savanna wrote:
Wed Oct 09, 2019 7:23 pm
I know there are people on this forum who code for a living, so would welcome anybody who would like to check my work.
I think that's a spot-on simulation of the problem at hand, given the assumptions we're using at least.

I would only make two small modifications, neither of which change the gist of it (they're just niceties). I've marked them with "JJ" comments:

Code: Select all

# Inputs
n <- 100000
years <- 10
meany <- 0.058
standy <- 0.114
x <- rep(1,n) # Vector of length n

# JJ: Set the PRNG seed, for reproducibility
set.seed(8675309)       # Actual constant used doesn't really matter

# do n trials of duration years
for (i in 1:years){
  x <- x * (1 + rnorm(n,meany,standy))
}
# check
mean(x)
(1+meany)^years

# JJ: A little easier than fooling with ordering, etc. :-)
1 - quantile(x, c(0.01, 0.05))