Skip to content
Prev 279341 / 398506 Next

problems using the thin plate spline method

Dear Jeff and R users,

Thanks Jeff. 

Your first plot suggestion worked. And when I stick dat$x1, dat$x2,dat$y, tpsfit seems to work as well. But it gives me a new error message 

tpsfit <- Tps(cbind(dat$x1, dat$x2), dat$y, scale.type="unscaled")

Warning message:
In gcv.Krig(out, nstep.cv = nstep.cv, verbose = verbose, cost = out$cost,  :
  Value of pure error estimate  is outside possible range

Then I get error messages for the subsequent lines as well.

I have now attached the data. And here is the full code I am trying to run. 


dat <- read.table("E:/thin plate/thin plate.csv", header=T, sep=",")
names(dat) <- c("x1", "x2", "y")
library(fields)
plot (dat)

#load the fields package (containing Tps) and fit a thin plate spline
tpsfit <- Tps(cbind(dat$x1, dat$x2), dat$y, scale.type="unscaled")

#predict the thin plate spline on the fine grid and plot the fitting
ngrid <- length(xf); grid <- cbind(rep(xf, ngrid), rep(xf, rep(ngrid, ngrid)))
out.p1 <- predict(tpsfit, grid)


persp(xf, xf, matrix(out.p1, ngrid, ngrid, byrow=F), theta=130, phi=20,
      expand=0.45, xlab="x1", ylab="x2", zlab="y", xlim=c(0,1), ylim=c(0,1),
      zlim=range(zf), ticktype="detailed", scale=F, main="gcv fitting")

Many thanks once again. 

regards
mintewab



Fr?n: Jeff Newmiller [jdnewmil at dcn.davis.ca.us]
Skickat: den 5 december 2011 12:39
Till: Mintewab Bezabih; Sarah Goslee
Kopia: r-help at r-project.org
?mne: Re: [R] problems using the thin plate spline method

Try

plot( dat$x1, dat$y )

or

plot( x1, y, data=dat )

Note that your example is still not reproducible because you have not supplied the data or a shortened version of your data for us to work with. Also, your problem is not with thin plates but with plot, and reading the help for that function by typing

?plot

at the R command line would have provided you with more examples and usage info on how to get around this problem.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Mintewab Bezabih <Mintewab.Bezabih at economics.gu.se> wrote: