summaryrefslogtreecommitdiff
path: root/CakeNullPlot.R
diff options
context:
space:
mode:
Diffstat (limited to 'CakeNullPlot.R')
-rw-r--r--CakeNullPlot.R17
1 files changed, 12 insertions, 5 deletions
diff --git a/CakeNullPlot.R b/CakeNullPlot.R
index 3eacd67..f5484b4 100644
--- a/CakeNullPlot.R
+++ b/CakeNullPlot.R
@@ -1,4 +1,4 @@
-#$Id: CakeNullPlot.R 216 2011-07-05 14:35:03Z nelr $
+#$Id$
# Generates model curves so the GUI can plot them. Used when all params are fixed so there was no fit
# The CAKE R modules are based on mkin
# Based on code in IRLSkinfit
@@ -19,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.”
-CakeNullPlot <- function(model, parms.ini, state.ini, observed, xlim = range(observed$time), digits = max(3, getOption("digits") - 3), ...)
+CakeNullPlot <- function(model, parms.ini, state.ini, observed, xlim = range(observed$time), digits = max(3, getOption("digits") - 3), sannMaxIter = 10000, ...)
{
# Print the fixed values
fixed <- data.frame(value = c(state.ini, parms.ini))
@@ -31,13 +31,20 @@ CakeNullPlot <- function(model, parms.ini, state.ini, observed, xlim = range(obs
obs_vars = unique(as.character(observed$name))
distimes <- data.frame(DT50 = rep(NA, length(obs_vars)),
DT90 = rep(NA, length(obs_vars)), row.names = obs_vars)
+ extraDT50<- data.frame(DT50 = rep(NA, 2), row.names = c("k1", "k2"))
+
for (obs_var in obs_vars) {
type = names(model$map[[obs_var]])[1]
if(exists("DT50")) distimes[obs_var, ] = c(DT50, DT90)
- distimes[obs_var, ] = CakeDT(type,obs_var,parms.ini)
+ distimes[obs_var, ] = CakeDT(type,obs_var,parms.ini,sannMaxIter)
}
+
cat("\nEstimated disappearance times:\n")
print(distimes, digits=digits,...)
+
+ extraDT50[ ,c("DT50")] = CakeExtraDT(type,parms.ini)
+ cat("\nHalf Lives for Extra k values:\n")
+ print(extraDT50, digits=digits,...)
# Plot the model
@@ -45,7 +52,7 @@ CakeNullPlot <- function(model, parms.ini, state.ini, observed, xlim = range(obs
odeini <- state.ini
odenames <- model$parms
- odeparms <- params.ini
+ odeparms <- parms.ini
# Solve the system
evalparse <- function(string)
@@ -86,7 +93,7 @@ CakeNullPlot <- function(model, parms.ini, state.ini, observed, xlim = range(obs
predicted_long <- mkin_wide_to_long(out_transformed,time="time")
# Calculate chi2 error levels according to FOCUS (2006)
- errmin<-CakeChi2(observed, predicted_long, obs_vars, c(), c())
+ errmin<-CakeChi2(model, observed, predicted_long, obs_vars, c("auto"), c(), state.ini, c("auto"))
cat("\nChi2 error levels in percent:\n")
errmin$err.min <- 100 * errmin$err.min
print(errmin, digits=digits,...)

Contact - Imprint