# Re: [R] Confidence Interval

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sun, 3 Feb 2008 00:22:52 +0000 (UTC)

David Winsemius <dwinsemius_at_comcast.net> wrote in news:Xns9A387C38610B7dNOTwinscomcast_at_80.91.229.13:

> "Jacques Wagnor" <jacques.wagnor@gmail.com> wrote in
>

```>> 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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help