From ce69b3045fd6866fa702a6925c9e92ad5617f05f Mon Sep 17 00:00:00 2001 From: Jonathan Dushoff Date: Mon, 26 Nov 2018 14:48:24 -0500 Subject: [PATCH 1/2] Added Re (with warning) to eval_min; not clear whether this is good --- R/impsamp.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/impsamp.R b/R/impsamp.R index ea74b92..78a1fdf 100644 --- a/R/impsamp.R +++ b/R/impsamp.R @@ -29,9 +29,9 @@ pop_pred_samp <- function(object, if (is.complex(ev)) { print(x) print(ev) - stop("covariance matrix with complex eigenvalues (!)") + warning("covariance matrix with complex eigenvalues (!)") } - min(ev) + min(Re(ev)) } ## extract var-cov, From dd2d25f7812600f4bd025c3bcf8951e230f2fb33 Mon Sep 17 00:00:00 2001 From: Jonathan Dushoff Date: Mon, 26 Nov 2018 15:26:52 -0500 Subject: [PATCH 2/2] Eliminated some sort of confusing underflow thing that was producing overflows --- R/impsamp.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/impsamp.R b/R/impsamp.R index 78a1fdf..938fabf 100644 --- a/R/impsamp.R +++ b/R/impsamp.R @@ -101,7 +101,11 @@ pop_pred_samp <- function(object, ## shift negative log-likelihoods (avoid underflow); ## find scaled likelihood L_wts <- L_wts - mv_wts ## subtract log samp prob - L_wts <- exp(L_wts - min(L_wts,na.rm=TRUE)) + + ## Hacking; fix if works + ## L_wts <- L_wts - min(L_wts,na.rm=TRUE) + L_wts <- exp(L_wts) + L_wts <- L_wts/sum(L_wts,na.rm=TRUE) eff_samp <- 1/sum(L_wts^2,na.rm=TRUE) ## check ??? res <- cbind(res,wts=L_wts)