[R] Error in integrate(int.fn, lower = 0, upper = Inf) : evaluation of function gave a result of wrong length
peter dalgaard
pdalgd at gmail.com
Mon Apr 9 15:35:25 CEST 2012
On Apr 9, 2012, at 14:54 , Guaramy wrote:
> I read it believe me . The reason that a i post this is because i am making a
> thesis and a i am having this problem for over 2 weeks.
> I can´t solve it and its causing me real problems.
Well, if you have a function that is not vectorized, i.e. it works for a single argument but not for a vector of arguments, and you want it to be vectorized, the tool is Vectorize(), the help page of which David pointed you to. (This essentially works around the problem by creating a new function which calls the function one vector element at the time.)
The direct cause of your problem seems to be that if x is a vector, so is y, and your temp.fn returns a vector, so int.fn returns a matrix, and integrate() is unhappy with that.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list