Message-ID: <7a09e3940803060613r7219b300o5d1d799e94c2c073@mail.gmail.com>
Date: 2008-03-06T14:13:38Z
From: Levi Waldron
Subject: differentiating a numeric vector
In-Reply-To: <001501c87f10$1ee5a570$7c94100a@win.ad.jhu.edu>
Thanks for all the ideas. splinefun looks like the simplest way to
achieve what I need:
> x <- 1:10
> y <- x^2
> f <- splinefun(x,y)
> f(3,deriv=0)
[1] 9
> f(3,deriv=1)
[1] 6
> f(3,2)
[1] 2
> f(3,3)
[1] -3.330669e-16
The fda package has a function bsplineS which does nearly the same
thing, and the SemiPar solution looks good for irregular x and y
values, but the built-in function seems to work for my purposes.