Re: [R] calculate quantiles of a custom function

2012-01-04 Thread Albyn Jones
FWIW, the integral of a mixture density is the same mixture of the CDFs, so you can use the pbeta functions: pcustom <- function(x) (pbeta(x,2,6) + pbeta(x,6,2))/2 albyn Quoting Gerhard : Am Dienstag, 3. Januar 2012, 19:51:36 schrieb Prof. Dr. Matthias Kohl: D <- AbscontDistribution(d = f

Re: [R] calculate quantiles of a custom function

2012-01-04 Thread Gerhard
Am Dienstag, 3. Januar 2012, 19:51:36 schrieb Prof. Dr. Matthias Kohl: > D <- AbscontDistribution(d = function(x) dbeta(x, 2, 6) + dbeta(x,6,2), > low = 0, up = 1, withStand = TRUE) Dear all, thank you all again for your help. So, summing up, (in case this might be useful to other beginners -

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Albyn Jones
right. replace dbetas with pbetas. albyn Quoting Duncan Murdoch : 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 quan

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Gerhard Schaden
Am Dienstag, 3. Januar 2012, 08:50:44 schrieb VictorDelgado: > VictorDelgado wrote > > > quantile(x) > > Correcting to > > quantile(q) > > - Dear Victor, thank you for your answer. Best, Gerhard > Victor Delgado > cedeplar.ufmg.br P.H.D. student > www.fjp.mg.gov.br reseacher > -- > Vie

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Prof. Dr. Matthias Kohl
Dear Gerhard, you could also use package "distr"; e.g. library(distr) ## use generating function "AbscontDistribution" D <- AbscontDistribution(d = function(x) dbeta(x, 2, 6) + dbeta(x,6,2), low = 0, up = 1, withStand = TRUE) ## quantiles q(D)(seq(0,1,0.1)) Best Matthias On 03.01.2012 19:3

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Duncan Murdoch
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

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Albyn Jones
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. albyn Quoting VictorDelgado : Gerhard wrot

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread VictorDelgado
VictorDelgado wrote > > > quantile(x) > > Correcting to quantile(q) - 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-tp4256887p4257575.html Sent from the R

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread VictorDelgado
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

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Gerhard
Am Dienstag, 3. Januar 2012, 11:05:11 schrieben Sie: > > The quick way is to look at the structure with 'str': > > str(integrate(myfunction,0,.9)) > List of 5 > $ value : num 1.85 > $ abs.error : num 2.05e-14 > $ subdivisions: int 1 > $ message : chr "OK" > $ call: l

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread David Winsemius
On Jan 3, 2012, at 7:24 AM, Gerhard wrote: Hi, I guess that my problem has an obvious answer, but I have not been able to find it. Suppose I create a custom function, consisting of two beta- distributions: myfunction <- function(x) { dbeta(x,2,6) + dbeta(x,6,2) } Given the symmetry

Re: [R] calculate quantiles of a custom function

2012-01-03 Thread Bert Gunter
Gerhard: Strictly speaking, it's quantiles of a custom "distribution", not function. There may be some way to handle your example easily, but, in general, you would need to solve the resulting integral equation. This is hard -- closed form solutions rarely exist; good approximations require work.