[R] calculate quantiles of a custom function

Albyn Jones jones at reed.edu
Tue Jan 3 22:23:56 CET 2012


right.  replace dbetas with pbetas.

albyn

Quoting Duncan Murdoch <murdoch.duncan at gmail.com>:

> On 03/01/2012 1:33 PM, Albyn Jones wrote:
>> What do quantiles mean here?  If you have a mixture density, say
>>
>>     myf<- function(x,p0) p0*dbeta(x,2,6) + (1-p0)*dbeta(x,6,2)
>>
>> then I know what quantiles mean.  To find the Pth quantile use uniroot
>> to solve for the x such that myf(x,p0) - P =0.
>
> You would want to integrate first...
>
> Duncan Murdoch
>
>> albyn
>>
>> Quoting VictorDelgado<victor.maia at fjp.mg.gov.br>:
>>
>>>
>>>  Gerhard wrote
>>>>
>>>>
>>>>  Suppose I create a custom function, consisting of two beta-distributions:
>>>>
>>>>  myfunction<- function(x) {
>>>>    dbeta(x,2,6) + dbeta(x,6,2)
>>>>  }
>>>>
>>>>  How can I calculate the quantiles of myfunction?
>>>>
>>>>  Thank you in advance,
>>>>
>>>>  Gerhard
>>>>
>>>>
>>>
>>>  Gehard, if do you want to know the quantiles of the new  
>>> distribution created
>>>  by "myfunction". Maybe you can also do:
>>>
>>>  x<- seq(0,1,.01) # insert your 'x'
>>>  q<- myfunction(x)
>>>  # And:
>>>  quantile(x)
>>>
>>>        0%      25%      50%      75%     100%
>>>  0.000000 1.476177 2.045389 2.581226 2.817425
>>>
>>>  # This gives the sample quantiles. You can also look foward to simulations
>>>  (like Bert Gunter had suggested) to know better the properties of
>>>  distributions quantiles obtained after 'myfunction'.
>>>
>>>
>>>
>>>  -----
>>>  Victor Delgado
>>>  cedeplar.ufmg.br P.H.D. student
>>>  www.fjp.mg.gov.br reseacher
>>>  --
>>>  View this message in context:
>>>   
>>> http://r.789695.n4.nabble.com/calculate-quantiles-of-a-custom-function-tp4256887p4257551.html
>>>  Sent from the R help mailing list archive at Nabble.com.
>>>
>>>  ______________________________________________
>>>  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.
>>>
>>>
>>
>> ______________________________________________
>> 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.
>
>
>



More information about the R-help mailing list