From ea197b16fe5c582dd2a72e81d25c1ebbd5d527b3 Mon Sep 17 00:00:00 2001 From: jranke Date: Mon, 23 Apr 2012 23:08:19 +0000 Subject: - Fixed a couple of things - Now the eigenvalue based solutions are nicely consistent with the deSolve solutions, if enough output times are specified (100, sometimes more are needed, see test.R) - Workaround for invilr not to produce NaN values so often - Still a lot to do (see TODO) git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@30 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- R/ilr.R | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'R/ilr.R') diff --git a/R/ilr.R b/R/ilr.R index b53f8683..389653e7 100644 --- a/R/ilr.R +++ b/R/ilr.R @@ -40,5 +40,12 @@ invilr<-function(x) { for (i in 1:D) { z[i] <- exp(y[i])/sum(exp(y)) } + + # Work around a numerical problem with NaN values returned by the above + # Only works if there is only one NaN value: replace it with 1 + # if the sum of the other components is < 1e-10 + if (sum(is.na(z)) == 1 && sum(z[!is.na(z)]) < 1e-10) + z = ifelse(is.na(z), 1, z) + return(z) } -- cgit v1.2.1