After reading the posts regrading thin plate spline and the "fields" package (here, here and here), i have some follow up questions:
consider this code to create a thin plate spline using the iris data set
data(iris)
library(fields)
library(plot3D)
x <- sep.l <- iris$Sepal.Length
y <- pet.l <- iris$Petal.Length
z <- sep.w <- iris$Sepal.Width
test.spline <- Tps(data.frame(x,y),z)
x2 <- seq(min(x), max(x), len=250)
y2 <- seq(min(y), max(y), len=250)
data <- expand.grid(x=x2, y=y2)
fitted <- matrix(predict(test.spline, data), 250,250)
persp3D(z=fitted, facets = FALSE, contour = TRUE, theta = 70, phi=30, ticktype="detailed", xlab="", ylab="", zlab="")
the code above creates a thin plate spline and then fit the model onto a mesh grid (i hope).
- how can i control the smoothing parameters of the spline - by using lambda or is it just by controlling the grid size?
- how can i add the actual points to the grid? i would like to see the regions where the fit is more robust
- is there a better way to go about it? am i missing something?
- is there a way to "slice" the resulted 3D surface into 2D graphs? i would like to show the 2D behavior in different values of y.