Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom knots for thin plate spline fails #5

Open
brycefrank opened this issue Aug 6, 2020 · 3 comments
Open

custom knots for thin plate spline fails #5

brycefrank opened this issue Aug 6, 2020 · 3 comments

Comments

@brycefrank
Copy link

Hello!

Thank you for the hard work on this package, it is incredibly exhaustive and useful.

One thing I am struggling with is fitting a thin plate spline with knots that are not at the sample locations. Here is an example that slightly modifies an example given in the manual:

library(fields)
data(ozone2)
y16<- ozone2$y[16,]
# there are some missing values -- remove them
good<- !is.na( y16)
y<- y16[good]
x<- ozone2$lon.lat[ good,]
#
# the knots can be arbitrary but just for fun find them with a space
# filling design. Here we select 50 from the full set of 147 points
#
xknots<- cover.design( x, 50, num.nn= 75)$design # select 50 knot points
Tps(x,y, knots=xknots)

I receive the error

Error in eigen(A + B, symmetric = TRUE) : 
  infinite or missing values in 'x'

I am able to fit a thin plate spline using knots not at the sample locations using some code I have written, but I would like to take advantage of this package to fit the lambda parameter. I have been using this publication for my own code so far:

Cicchitelli, Giuseppe, and Giorgio E. Montanari. "Model‐assisted estimation of a spatial population mean." International Statistical Review 80, no. 1 (2012): 111-126.

Any insight on why this error is showing up would be helpful.

@dnychka
Copy link
Contributor

dnychka commented Aug 11, 2020 via email

@brycefrank
Copy link
Author

brycefrank commented Aug 12, 2020

Doug,

It is no problem! I did a bit of digging myself and could not find any obvious issues. It is clear that there are three negative values in the eigenvalues. If I remember correctly it was around here:

hold.AB <- eigen(A + B, symmetric = TRUE)

Although it could have been in fields.diagonalize.R, I can't recall. This leads to the error when the square root is taken here:

hold.AB <- (t(hold.AB$vectors) * (1/sqrt(hold.AB$values)))

In any case I have moved on to another method for my own reasons so it is not urgent.

@dnychka
Copy link
Contributor

dnychka commented Aug 12, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants