[R] R's integrate function
Charles C. Berry
cberry at tajo.ucsd.edu
Wed Oct 1 00:08:19 CEST 2008
On Tue, 30 Sep 2008, Susanne Pfeifer wrote:
> Hi,
>
> sorry, I was a bit confused and my function looked slightly different
> from the one I posted before:
In any case, you will not get far trying to integrate this one for values
of z like 12000 without doing some homework. Simply plugging the function
into 'integrate' won't get an accurate answer.
The function you have has a narrow spike with a lot of mass near the
origin when
z=12000.
The answer you got is off by orders of magnitude. (Try changing the limits
of integration to (0,0.1) and compare to what you got with (0,1) to see
this).
You'll need to come up with a better method of finding this integral.
HTH,
Chuck
>
> Susanne Pfeifer schrieb:
>>>> integrate(function(y,z){
>>> + sapply(y, function(y,z){
>>> + integrate(function(x,z)
>>> +
>>> 1/x*dbeta(0.01,x/(0.005/1.005),(1-x)/(0.005/1.005))*dbeta(y,x/(0.005/1.005),(1-x)/(0.005/1.005))*(1-y)^z,0,1
>>>
>>> + ,423)$value
>>> + })
>>> + },0,1,423)
>
> integrate(function(y,z){
> sapply(y, function(y,z){
> integrate(function(x,z)
> 1/x*dbeta(0.01,x/(0.01/1.01),(1-x)/(0.01/1.01))*dbeta(y,x/(0.01/1.01),(1-x)/(0.01/1.01))*(1-y)^z,0,1,12000)$value
> })
> },0,1,12000)
>
> Sorry for the confusion...
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help
mailing list