Jos?? Fernando Silva wrote:
> I have a simple doubt:
> I have a function, say:
>
> test <- function (theta) {
> return (theta^2) }
>
> I can use:
> integrate (test,0,1)
> to obtain the area under de function.
> Can I do the opposite? I`d like to give the lower limit and the area I need
as arguments, in order to get the upper limit. In other words, I`d like to
obtain the quantile of the function (the lower limit could be 0, for example).
> Thank you in advance.
>
If you really want to do it numerically (assuming your function is much
more complex and the exmaple one), try e.g.
solveit <- function (quant, foo, lw, area) {
(integrate(foo, lw, quant)$value - area)^2
}
optimize(solveit, c(0, 100),
foo = function(theta) theta^2, lw = 0, area = 0.95)
Uwe Ligges
>
>
> ---------------------------------
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html