aboutsummaryrefslogtreecommitdiff
path: root/R/mkinfit.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-11-03 16:07:59 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-11-03 16:07:59 +0100
commit96c8558842e2494f42c0e148fb8d8f422000ecde (patch)
tree6d92a453bd977cdf5ff3daf7562a9bd3218028a4 /R/mkinfit.R
parenta5874ab7fce4616e80be69366ff0685332f47bf1 (diff)
Do not test residuals per default, improve nlme.mmkin
Do not give starting values for random effects in nlme.mmkin.
Diffstat (limited to 'R/mkinfit.R')
-rw-r--r--R/mkinfit.R16
1 files changed, 10 insertions, 6 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

Contact - Imprint