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

Eigvalue of 0 in some instances #17

Closed
lukesonnet opened this issue Oct 30, 2017 · 26 comments
Closed

Eigvalue of 0 in some instances #17

lukesonnet opened this issue Oct 30, 2017 · 26 comments

Comments

@lukesonnet
Copy link
Owner

There are some cases where R is returning an eigenvalue of 0 in the generateK() function. This causes all sorts of problems downstream. This seems to only happen without truncation, and is thus caused by R's default eigen() function. Should I prevent this by adding the minimum double R can handle to 0 eigenvalues? I very rarely run into it and it's only when lambda is very large and there is no truncation.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 30, 2017 via email

@lukesonnet
Copy link
Owner Author

D^-1 is used in the solution so I don't think option 1 is viable.

Option 2: There are some eigvals that have nonzero (but 1e-19 or so) values after the one that is an actual 0, so that doesn't seem to work.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 30, 2017 via email

@lukesonnet
Copy link
Owner Author

lukesonnet commented Oct 30, 2017 via email

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 30, 2017 via email

@lukesonnet
Copy link
Owner Author

Okay, so I currently resolve this problem with:

D <- ifelse(eigobj$values < .Machine$double.eps, .Machine$double.eps, eigobj$values)

But this only runs if truncate = F. Note, this is going to take some of those values that are < 2e-16 and increase them to that amount. I suppose that's not really a problem, and this seems to be a pretty rare case.

@lukesonnet
Copy link
Owner Author

The problem with using this rule is that we are changing estimates. There are many cases where we get eigvals < 2e-16 that aren't actually 0 that work. So we would have our first departure from past KRLS results. I don't think this is a good solution.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@lukesonnet
Copy link
Owner Author

I think we should just go ahead with the truncation. I think this would have failed with the initial package, unfortunately I don't have a reproducible example. I'll see if I can recreate this bug.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@lukesonnet
Copy link
Owner Author

My only concern is that this is a rare case and we are adding an equality check in the generateK function for it. Anyways, shouldn't be too expensive and is now implemented.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@lukesonnet
Copy link
Owner Author

lukesonnet commented Oct 31, 2017 via email

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@lukesonnet
Copy link
Owner Author

Ok, in our KRLS what is happening is that sometimes one of the eigenvalues between the positive and the negative eigenvalues slips to 0. In the same data, original KRLS somehow gets away with an eigenvalue of -3.081488e-33.

@lukesonnet
Copy link
Owner Author

The difference lies in the fact that we use kern_gauss (a cpp function) to build K while the original KRLS uses gausskernel to build K. I believe there is less precision in the cpp version and that is carrying through to the eigen decomposition.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@lukesonnet
Copy link
Owner Author

Right, I was wondering why that existed at all.

@lukesonnet
Copy link
Owner Author

Presumably numerical error on the part of eigen or in the kernel matrix itself.

@lukesonnet
Copy link
Owner Author

lukesonnet commented Oct 31, 2017

I have a feeling that if we truncate at 0 or below, we are not going to be backwards compatible in many cases (i.e. many use cases actually will produce neg eigenvalues)

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@chadhazlett
Copy link
Collaborator

chadhazlett commented Oct 31, 2017 via email

@lukesonnet
Copy link
Owner Author

I'll add that issue but I'll work on it later.

@chadhazlett
Copy link
Collaborator

chadhazlett commented Nov 1, 2017 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