[R] Confidence Interval
David Winsemius
dwinsemius at comcast.net
Sun Feb 3 01:22:52 CET 2008
David Winsemius <dwinsemius at comcast.net> wrote in
news:Xns9A387C38610B7dNOTwinscomcast at 80.91.229.13:
> "Jacques Wagnor" <jacques.wagnor at gmail.com> wrote in
> news:787911d50802011830s6f5db31i2e625f3add5b81f5 at mail.gmail.com:
>
>> I have a model as follows:
>>
>> x <- replicate(100, sum(rlnorm(rpois(1,5), 0,1)))
>> y <- quantile(x, 0.99))
>>
>> How would one go about estimating the boundaries of a 95%
>> confidence interval for y?
>>
>> Any pointers would be greatly appreciated.
>
> I'm not a statistician, so giving the answer in terms of extreme
> value statistics is beyond me, but the R Team gives us a (sharp)
> tool.
>
> quantile(x,99) is returning the midpoint of the 99th and 100th
> elements of the sorted 100 element vector you created.
>
> If you repeat that process 1000 times, sort again, and pick the 25th
> and the 975th points, you can pull the 0.025 and 97.5 percentile
> points from the simulated distribution. Obviously an estimate and
> will vary depending on the seed.
>
> Here's what I got after that process:
>> sort(y1000.df$midpt)[25]
> [1] 20.8424
>> sort(y1000.df$midpt)[1000-25]
> [1] 47.47615
>
My apologies to Ivan Frohne and Rob J Hyndman, the authors of
stats:::quantile. After looking further at the type definition for the
default interpolation algorithm (type = 7), I do not think my
description offered above is accurate.
Jacques, you should not worry if your simulations produce more narrow
bounds for the 99th percentile. When I use quantile(), rather than my
imagined behavior of it, and do 10,000 iterations, I get results that
are somewhat different:
+ ))[c(250,9750)]
99% 99%
19.11080 38.56948
--
David Winsemius
More information about the R-help
mailing list