aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/mkinfit.R16
-rw-r--r--R/nlme.mmkin.R2
-rw-r--r--man/mkinfit.Rd3
3 files changed, 14 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)
diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 7f5092c5..8f10ea0a 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -28,6 +28,7 @@ mkinfit(
reweight.tol = 1e-08,
reweight.max.iter = 10,
trace_parms = FALSE,
+ test_residuals = FALSE,
...
)
}
@@ -186,6 +187,8 @@ the error model parameters in IRLS fits.}
\item{trace_parms}{Should a trace of the parameter values be listed?}
+\item{test_residuals}{Should the residuals be tested for normal distribution?}
+
\item{\dots}{Further arguments that will be passed on to
\code{\link[deSolve:ode]{deSolve::ode()}}.}
}

Contact - Imprint