summaryrefslogtreecommitdiff
path: root/CakeOlsFit.R
diff options
context:
space:
mode:
Diffstat (limited to 'CakeOlsFit.R')
-rw-r--r--CakeOlsFit.R15
1 files changed, 10 insertions, 5 deletions
diff --git a/CakeOlsFit.R b/CakeOlsFit.R
index 75ac471..626a595 100644
--- a/CakeOlsFit.R
+++ b/CakeOlsFit.R
@@ -7,11 +7,11 @@
# from the FME package, v 1.1 by Soetart and Petzoldt, which was in turn
# inspired by summary.nls.lm
-#$Id: CakeOlsFit.R 216 2011-07-05 14:35:03Z nelr $
+#$Id$
# This version has been modified to expect SFO parameterised as k and flow fractions
# Modifications developed by Tessella Plc for Syngenta: Copyright (C) 2011 Syngenta
-# Authors: Rob Nelson, Richard Smith
-# Tessella Project Reference: 6245
+# Authors: Rob Nelson, Richard Smith, Tamar Christina
+# Tessella Project Reference: 6245, 7247
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@ CakeOlsFit <- function(mkinmod, observed,
plot = FALSE, quiet = FALSE,
err = NULL, weight = "none", scaleVar = FALSE,
atol = 1e-6,
+ sannMaxIter = 10000,
+ useSolnp = FALSE, method='L-BFGS-B',
...)
{
mod_vars <- names(mkinmod$diffs)
@@ -294,20 +296,23 @@ CakeOlsFit <- function(mkinmod, observed,
fit$fixed$type = c(rep("state", length(state.ini.fixed)), rep("deparm", length(parms.fixed)))
# # Calculate chi2 error levels according to FOCUS (2006)
- fit$errmin <- CakeChi2(observed, predicted_long, obs_vars, parms.optim, state.ini.optim)
+ fit$errmin <- CakeChi2(mkinmod, observed, predicted_long, obs_vars, parms.optim, state.ini.optim, state.ini, parms.ini)
# Calculate dissipation times DT50 and DT90 and formation fractions
parms.all = c(fit$par, parms.fixed)
fit$distimes <- data.frame(DT50 = rep(NA, length(obs_vars)), DT90 = rep(NA, length(obs_vars)),
row.names = obs_vars)
+ fit$extraDT50<- data.frame(DT50 = rep(NA, 2), row.names = c("k1", "k2"))
+
fit$ff <- vector()
fit$SFORB <- vector()
for (obs_var in obs_vars) {
type = names(mkinmod$map[[obs_var]])[1]
- fit$distimes[obs_var, ] = CakeDT(type,obs_var,parms.all)
+ fit$distimes[obs_var, ] = CakeDT(type,obs_var,parms.all,sannMaxIter)
}
+ fit$extraDT50[ ,c("DT50")] = CakeExtraDT(type,parms.all)
fit$penalties <- CakePenaltiesLong(parms.all, out_predicted, observed)
# Collect observed, predicted and residuals

Contact - Imprint