[R] Cubic B-spline, how to numerically integrate?
Frank E Harrell Jr
f.harrell at Vanderbilt.Edu
Fri May 14 20:55:51 CEST 2010
On 05/14/2010 11:36 AM, David Winsemius wrote:
>
> On May 14, 2010, at 11:57 AM, David Winsemius wrote:
>
>>
>> On May 14, 2010, at 11:41 AM, Claudia Penaloza wrote:
>>
>>> (corrected version of previous posting)
>>>
>>> I fit a GAM to turtle growth data following methods in Limpus &
>>> Chaloupka
>>> 1997 (http://www.int-res.com/articles/meps/149/m149p023.pdf).
>>>
>>> I want to obtain figures similar to Fig 3 c & f in Limpus & Chaloupka
>>> (1997), which according to the figure legend are "expected size-at-age
>>> functions" obtained by numerically integrating "size-specific growth
>>> rate
>>> functions derived using cubic B-spline fit to GAM predicted values".
>>>
>>> I was able to fit the cubic-B spline, but I do not know how to
>>> "numerically
>>> integrate" it.
>>
>> You need to give us the function and the appropriate limits of
>> integration.
>
> Maybe it is even easier than I thought. Assuming your interest lies with
> the last fitted line ... the one on the third page ... you could perhaps
> just see how successful this strategy would be:
>
> # Presumably you have already done:
> # requite(mgcv)
>
> Int.fit <- seq(100, 600, by=0.1)*predict(bspline3,
> newdata=data.frame(size=seq(100, 600, by=0.1) ) )
>
> You would need to do a sensibility check by comparing the result to a
> back of the envelope estimate: say 55*500=27500 . I'm a bit concerned
> that a dimensional analysis suggest this is an estimate of mm^2/yr,
> although I suppose a yearly surface area increase could be a meaningful
> value in some domain or another
>
>>
>>>
>>> Can anybody help please?
>>>
>>> Code and figures here:
>>> https://docs.google.com/fileview?id=0B1cQ7z9xYFl2ZTZhMmMyMjAtYTA3Zi00N2QyLTkxNzMtOGYyMjdiOGU2ZWE4&hl=en
>>>
>>>
>>> Thank you,
>>> Claudia
>> --
>>
>> David Winsemius, MD
>> West Hartford, CT
There are advantages to using the truncated power basis for splines.
Derivatives and antiderivatives are trivial to write down. The Hmisc
package has rcspline.eval and rcspline.restate functions to help, the
latter having an option to express the antiderivative in text form.
Frank
--
Frank E Harrell Jr Professor and Chairman School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list