aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/mkinparplot.R53
-rw-r--r--man/mkinparplot.Rd35
2 files changed, 88 insertions, 0 deletions
diff --git a/R/mkinparplot.R b/R/mkinparplot.R
new file mode 100644
index 0000000..8e8de02
--- /dev/null
+++ b/R/mkinparplot.R
@@ -0,0 +1,53 @@
+# Copyright (C) 2014 Johannes Ranke
+# Contact: jranke@uni-bremen.de
+
+# This file is part of the R package mkin
+
+# mkin is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>
+mkinparplot <- function(object) {
+ state.optim = rownames(subset(object$start, type == "state"))
+ deparms.optim = rownames(subset(object$start, type == "deparm"))
+ fractions.optim = grep("^f_", deparms.optim, value = TRUE)
+ if ("g" %in% deparms.optim) fractions.optim <- c("g", fractions.optim)
+ rates.optim = setdiff(deparms.optim, fractions.optim)
+ n.plot <- c(state.optim = length(state.optim),
+ rates.optim = length(rates.optim),
+ fractions.optim = length(fractions.optim))
+ n.plot <- n.plot[n.plot > 0]
+
+ layout(matrix(1:length(n.plot), ncol = 1), heights = n.plot + 1)
+
+ s <- summary(object)
+ bpar <- data.frame(t(s$bpar))
+ oldpars <- par(no.readonly = TRUE)
+ par(mar = c(2.1, 2.1, 0.1, 2.1))
+ for (type in names(n.plot)) {
+ parnames <- get(type)
+ values <- bpar[parnames]
+ xlim = switch(type,
+ state.optim = range(c(0, unlist(values)),
+ na.rm = TRUE, finite = TRUE),
+ rates.optim = range(unlist(values),
+ na.rm = TRUE, finite = TRUE),
+ fractions.optim = range(c(0, 1, unlist(values)),
+ na.rm = TRUE, finite = TRUE))
+ stripchart(bpar[get(type)], xlim = xlim,
+ yaxt = "n", ylim = c(0.5, length(get(type)) + 0.5))
+ text(mean(xlim), 1:length(parnames), parnames, pos = 3, offset = 1)
+ arrows(as.numeric(values["Lower", ]), 1:length(parnames),
+ as.numeric(values["Upper", ]), 1:length(parnames),
+ code = 3, angle = 90, length = 0.1)
+ }
+ par(oldpars)
+}
diff --git a/man/mkinparplot.Rd b/man/mkinparplot.Rd
new file mode 100644
index 0000000..60103b8
--- /dev/null
+++ b/man/mkinparplot.Rd
@@ -0,0 +1,35 @@
+\name{mkinparplot}
+\alias{mkinparplot}
+\title{
+ Function to plot the confidence intervals obtained using
+ \code{\link{mkinfit}}
+}
+\description{
+ This function plots the confidence intervals for the parameters
+ fitted using \code{\link{mkinfit}}.
+}
+\usage{
+ mkinparplot(object)
+}
+\arguments{
+ \item{object}{
+ A fit represented in an \code{\link{mkinfit}} object.
+ }
+}
+\value{
+ Nothing is returned by this function, as it is called for its side effect, namely to produce a plot.
+}
+\author{
+ Johannes Ranke
+}
+
+\examples{
+model <- mkinmod(
+ T245 = list(type = "SFO", to = c("phenol")),
+ phenol = list(type = "SFO", to = c("anisole")),
+ anisole = list(type = "SFO"), use_of_ff = "max")
+fit <- mkinfit(model, subset(mccall81_245T, soil == "Commerce"),
+ parms.ini = c(f_phenol_to_anisole = 1), fixed_parms = "f_phenol_to_anisole")
+\dontrun{mkinparplot(fit)}
+}
+\keyword{ hplot }

Contact - Imprint