[R] calculate quantiles of a custom function
Gerhard
feldspat at gmx.net
Tue Jan 3 17:17:02 CET 2012
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 : language integrate(f = myfunction, lower = 0, upper
> = 0.9)
> - attr(*, "class")= chr "integrate"
>
> The longer way would be to look at the help)integrate) page where the
> "Value" section would have told you that a list with named components
>
> was returned:
> > integrate(myfunction,0,.9)$value
>
> [1] 1.850299
>
> In this instance you could also probably use 'cumsum' (which is just
> doing the numerical integration by hand
>
> plot(cumsum( myfunction(seq(0,1,by=0.001)))/
> sum(myfunction(seq(0,1,by=0.001)) ) )
Thanks a lot; now I now where I need to look for help before bothering you
again.
Best,
Gerhard
>
> > I need to hand on the value to another function, and then I get an
> > error
> > message, because the output of integrate is not a numerical argument.
> >
> >>> I have not seen any continous function treated in the docs, and
> >>> applying the
> >>> "quantile function" gives me an error (since it seems only to be
> >>> defined on
> >>> lists and atoms).
> >>
> >> There is also a family of packages, all of whose names begin with
> >> "distr". They provide a variety of facilities for developing new
> >> distributions, both discrete and continuous.
> >
> > That looks quite frightening. But if it turns out to be necessary.
>
> But a good way to improve you knowledge of statistical concepts.
>
> > Thank you,
> >
> > Gerhard
>
> David Winsemius, MD
> West Hartford, CT
More information about the R-help
mailing list