I don't believe you did anything wrong here, just that integrate()
itself isn't (can't?) be vectorized.
E.g.,
x <- integrate(function(x) x^2, 0, 2)
y <- integrate(function(x) x^2, 0, c(2,3))
identical(x, y) # FALSE -- so there's a difference.
# Take a look
str(x)
str(y)
# It's just in the call
Dear David and Micheal,
thanks for your suggestion. Vectorize does what I need.
David you suggest me that I didn't built the function in a manner that
would vectorize. Could you please explain me what's wrong?
Thanks,
Mauro
>
> On Mar 15, 2012, at 6:08 AM, Mauro Rossi wrote:
>
>> Dear R users,
On Mar 15, 2012, at 6:08 AM, Mauro Rossi wrote:
Dear R users,
first I take this opportunity to greet all the R community for
your continuous efforts.
I wrote a function to calculate the pdf and cdf of a custom
distribution (mixed gamma model).
The function is the following:
pmixedgamma
I believe the difficulty is that the integrate function isn't
vectorized: add this line and you should be good
pmixedgamma3 <- Vectorize(pmixedgamma3)
Read ? Vectorize for details if you only need to vectorize certain arguments.
Michael
On Thu, Mar 15, 2012 at 6:08 AM, Mauro Rossi wrote:
> Dea
Dear R users,
first I take this opportunity to greet all the R community for your
continuous efforts.
I wrote a function to calculate the pdf and cdf of a custom distribution
(mixed gamma model).
The function is the following:
pmixedgamma3 <- function(y, shape1, rate1, shape2, rate2, prev)
5 matches
Mail list logo