aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/mkinfit.R16
-rw-r--r--R/nlme.mmkin.R2
2 files changed, 11 insertions, 7 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 65dd5d75..1b1bb73d 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -148,6 +148,7 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("name", "time", "value"))
#' the error model parameters in IRLS fits.
#' @param reweight.max.iter Maximum number of iterations in IRLS fits.
#' @param trace_parms Should a trace of the parameter values be listed?
+#' @param test_residuals Should the residuals be tested for normal distribution?
#' @param \dots Further arguments that will be passed on to
#' [deSolve::ode()].
#' @importFrom stats nlminb aggregate dist shapiro.test
@@ -254,6 +255,7 @@ mkinfit <- function(mkinmod, observed,
error_model_algorithm = c("auto", "d_3", "direct", "twostep", "threestep", "fourstep", "IRLS", "OLS"),
reweight.tol = 1e-8, reweight.max.iter = 10,
trace_parms = FALSE,
+ test_residuals = FALSE,
...)
{
call <- match.call()
@@ -933,12 +935,14 @@ mkinfit <- function(mkinmod, observed,
# Assign the class here so method dispatch works for residuals
class(fit) <- c("mkinfit")
- # Check for normal distribution of residuals
- fit$shapiro.p <- shapiro.test(residuals(fit, standardized = TRUE))$p.value
- if (fit$shapiro.p < 0.05) {
- shapiro_warning <- paste("Shapiro-Wilk test for standardized residuals: p = ", signif(fit$shapiro.p, 3))
- warning(shapiro_warning)
- summary_warnings <- c(summary_warnings, S = shapiro_warning)
+ if (test_residuals) {
+ # Check for normal distribution of residuals
+ fit$shapiro.p <- shapiro.test(residuals(fit, standardized = TRUE))$p.value
+ if (fit$shapiro.p < 0.05) {
+ shapiro_warning <- paste("Shapiro-Wilk test for standardized residuals: p = ", signif(fit$shapiro.p, 3))
+ warning(shapiro_warning)
+ summary_warnings <- c(summary_warnings, S = shapiro_warning)
+ }
}
fit$summary_warnings <- summary_warnings
diff --git a/R/nlme.mmkin.R b/R/nlme.mmkin.R
index 6d24a044..e8418ebd 100644
--- a/R/nlme.mmkin.R
+++ b/R/nlme.mmkin.R
@@ -150,7 +150,7 @@ nlme.mmkin <- function(model, data = sys.frame(sys.parent()),
thisCall[["data"]] <- nlme_data(model)
if (missing(start)) {
- thisCall[["start"]] <- mean_degparms(model, random = TRUE)
+ thisCall[["start"]] <- mean_degparms(model, random = FALSE)
}
thisCall[["fixed"]] <- lapply(as.list(dp_names), function(el)

Contact - Imprint