From 5b87e5d81a42d36616678fd65889b352cc8d6ff3 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 15 Sep 2018 11:03:08 +0200 Subject: Remove correlation test as gmkin on windows still crashes Clean up the code a bit --- R/mkinfit.R | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/R/mkinfit.R b/R/mkinfit.R index dec55a4e..2f05e81a 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -413,21 +413,12 @@ mkinfit <- function(mkinmod, observed, } if (reweight.method == "tc") { # We need unweighted residuals to update the weighting - cost_tmp <- cost(fit$par) - - # We need to supress warnings as we may have ties - p_tmp <- suppressWarnings(cor.test(abs(cost_tmp$residuals$res.unweighted), - cost_tmp$residuals$obs, method = "kendall")$p.value) - - if (p_tmp > 0.1) { - stop("No correlation of absolute residuals with observed values found.\n", - "Try without reweighting or with reweight.method = 'obs'.") - } + tmp_res <- cost(fit$par)$residuals tc_fit <- try( nls(abs(res.unweighted) ~ sigma_twocomp(obs, sigma_low, rsd_high), start = list(sigma_low = tc["sigma_low"], rsd_high = tc["rsd_high"]), - data = cost_tmp$residuals, + data = tmp_res, lower = 0, algorithm = "port")) @@ -467,13 +458,14 @@ mkinfit <- function(mkinmod, observed, sr_new <- fit$var_ms_unweighted } if (reweight.method == "tc") { - cost_tmp <- cost(fit$par) - - tc_fit <- try(nls(abs(res.unweighted) ~ sigma_twocomp(obs, sigma_low, rsd_high), - start = as.list(tc_fitted), - data = cost_tmp$residuals, - lower = 0, - algorithm = "port")) + tmp_res <- cost(fit$par)$residuals + + tc_fit <- try( + nls(abs(res.unweighted) ~ sigma_twocomp(obs, sigma_low, rsd_high), + start = list(sigma_low = tc["sigma_low"], rsd_high = tc["rsd_high"]), + data = tmp_res, + lower = 0, + algorithm = "port")) if (inherits(tc_fit, "try-error")) { stop("Estimation of the two error model components failed during reweighting.\n", -- cgit v1.2.1