
In a reply to my inquiry, a respondent offered the following simulation code:

> lens <- rpois(100000, 3)

> V <- numeric(100000)

> for(i in 1:length(lens)) V[i] <- sum(rnorm(lens[i]))

> quantile(V, c(.95, .99))

The code worked exactly the way I wanted. I had an Excel model that does the same thing. The quantiles from both models were almost identical. Two follow-up questions:

1. I also did a mean(V), but the result I got in R was 5 times greater than the result I got using the Excel model. Any idea why that might be?

2. When I tried using the random generation from the Generalized Pareto Distribution, I kept getting an error as follows:

"Error in rgpd(lens[i]) : Argument "xi" is missing, with no default"

My code was:

> for(i in 1:length(lens)) V[i] <- sum(rgpd(lens[i]),0.5,mu=0.1,beta=0.8)

Note: rgpd() is part of library(evir); a Windows version of which can be downloaded at 

http://www.maths.lancs.ac.uk/~stephena/software/win.html

Many thanks!


	[[alternative HTML version deleted]]


