Re: [R] 3-d splinefun

From: Dave Roberts <droberts_at_montana.edu>
Date: Sat 11 Feb 2006 - 02:28:04 EST

Colby,

     Function surf() in package labdsv uses the gam() function from mgcv to do this in conjunction with akima. You might want to look at that routine for an idea. Currently it fits the gam as z <- gam(s(x) + s(y), but it's possible in the mgcv version of gam to fit z <- gam(s(x,y)) as well. The gam function gives a good interpolation with measured error and appropriate fit statistics.


David W. Roberts                                     office 406-994-4548
Professor and Head                                      FAX 406-994-3190
Department of Ecology                         email droberts@montana.edu
Montana State University
Bozeman, MT 59717-3460

Colby Tanner wrote:
> hello,
> is it possible to do something like splinefun(x,y), but with a 3rd
> dim?
> for example, if i have a 2-dim system like:
> x<-1:100
> y<-rexp(100,1)
> func<-splinefun(x,sort(y))
>
> func(n) # returns interpolated value of y (after sorting) given x=n
> # i can check this by:
>
> plot(x,sort(y))
> lines(spline(x,sort(y)))
>
>
> Can i do the same thing with an x,y, and z? i have found the akima
> interp(x,y,z) for building 3-d images, but nothing about the function
> aspect. besides building a nice 3-dim image, i would like to have a
> way of finding the interpolated z values if i give an x and y
> coordinate. something like func(x,y) in the above example.
>
> thank you,
> colby
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

--

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Feb 11 02:40:04 2006

This archive was generated by hypermail 2.1.8 : Mon 13 Feb 2006 - 22:41:22 EST