summaryrefslogtreecommitdiff
path: root/inst/doc/kinfit.Rnw
diff options
context:
space:
mode:
Diffstat (limited to 'inst/doc/kinfit.Rnw')
-rw-r--r--inst/doc/kinfit.Rnw83
1 files changed, 82 insertions, 1 deletions
diff --git a/inst/doc/kinfit.Rnw b/inst/doc/kinfit.Rnw
index a433e44..3292fd1 100644
--- a/inst/doc/kinfit.Rnw
+++ b/inst/doc/kinfit.Rnw
@@ -1,3 +1,4 @@
+% $Id: kinfit.Rnw 125 2011-11-10 07:19:59Z jranke $
%%\VignetteIndexEntry{Routines for fitting kinetic models to chemical degradation data}
%%VignetteDepends{nls}
%%\usepackage{Sweave}
@@ -680,7 +681,7 @@ model are hardly distinguishable. As a consequence, the software packages
strongly disagree especially on the model parameter $f$ specifying the
distribution between the kinetic domains that are characterised by the
two kinetic constants. Again, the \Rpackage{kinfit} routine does not
-show conversion for this model and this dataset (Table \ref{tab:vali.DFOP.A}).
+show convergence for this model and this dataset (Table \ref{tab:vali.DFOP.A}).
Fitting the DFOP model with \Rpackage{kinfit} to dataset B yields results
that are very close to the median of the results obtained by other packages,
@@ -912,6 +913,86 @@ The comparison shows that whenever a minimum error level $\chi^2$ was
calculated using the \Rpackage{kinfit} package, it was very close to
the value generated by KinGUI.
+\subsection{$R^2$ value}
+
+In a similar manner, the coefficient of determination calculated by kinfit
+according to the formula
+
+\begin{equation}
+R^2 = 1 - RSS / TSS
+\end{equation}
+
+where RSS is the sum of squares of the residuals and TSS is the sum of squares
+of the deviations from the mean value is compared to the model efficiency EF
+calculated by KinGUI based on the same formula (FOCUS 2006, p. 99) as shown
+in Table \ref{tab:vali.R2}. This exercise was done for FOCUS datasets A to D
+only.
+
+<<KinGUI_write, echo=FALSE>>=
+R2.SFO.kinfit <- R2.FOMC.kinfit <- array(dim = 4,
+ dimnames = list(names(kinobjects[1:4])))
+R2.DFOP.kinfit <- R2.HS.kinfit <- array(dim = 4,
+ dimnames = list(names(kinobjects[1:4])))
+for (kinobjectname in names(kinobjects[1:4]))
+{
+ R2.SFO.kinfit[[kinobjectname]] <-
+ kinobjects[[kinobjectname]]$results$stats[["SFO", "R2"]]
+ R2.FOMC.kinfit[[kinobjectname]] <-
+ ifelse(class(kinobjects[[kinobjectname]]$fits$FOMC) == "try-error",
+ NA, kinobjects[[kinobjectname]]$results$stats[["FOMC", "R2"]])
+ R2.DFOP.kinfit[[kinobjectname]] <-
+ ifelse(class(kinobjects[[kinobjectname]]$fits$DFOP) == "try-error",
+ NA, kinobjects[[kinobjectname]]$results$stats[["DFOP", "R2"]])
+ R2.HS.kinfit[[kinobjectname]] <-
+ ifelse(class(kinobjects[[kinobjectname]]$fits$HS) == "try-error",
+ NA, kinobjects[[kinobjectname]]$results$stats[["HS", "R2"]])
+}
+
+EF.SFO.KinGUI <- c(0.9845, 0.9971, 0.9714, 0.9919)
+EF.FOMC.KinGUI <- c(0.9831, 0.9973, 0.9955, 0.9920)
+EF.HS.KinGUI <- c(0.9972, 0.9972, 0.9980, 0.9945)
+EF.DFOP.KinGUI <- c(0.9845, 0.9973, 0.9994, 0.9919)
+names(EF.SFO.KinGUI) <- names(EF.FOMC.KinGUI) <- names(kinobjects[1:4])
+names(EF.DFOP.KinGUI) <- names(EF.HS.KinGUI) <- names(kinobjects[1:4])
+
+R2 <- data.frame(
+ SFO.KinGUI = EF.SFO.KinGUI,
+ SFO.kinfit = round(R2.SFO.kinfit, 4),
+ FOMC.KinGUI = EF.FOMC.KinGUI,
+ FOMC.kinfit = round(R2.FOMC.kinfit, 4),
+ DFOP.KinGUI = EF.DFOP.KinGUI,
+ DFOP.kinfit = round(R2.DFOP.kinfit, 4),
+ HS.KinGUI = EF.HS.KinGUI,
+ HS.kinfit = round(R2.HS.kinfit, 4)
+)
+write.table(R2,
+ file = "R2_comparison.tex",
+ sep=" & ", quote=FALSE, na="",
+ row.names=TRUE, col.names=FALSE, eol = " \\\\ \n")
+@
+
+\begin{table}
+\caption{Comparison of model efficiency (EF) values calculated
+by KinGUI and $R^2$ values calculated by \Rpackage{kinfit}. \label{tab:vali.R2}}
+\vspace{0.5cm}
+\begin{tabular}{lcccccccc}
+\toprule
+ & \multicolumn{2}{c}{SFO} &
+\multicolumn{2}{c}{FOMC} &
+\multicolumn{2}{c}{DFOP} &
+\multicolumn{2}{c}{HS} \\
+Dataset & KinGUI & \Rpackage{kinfit} & KinGUI & \Rpackage{kinfit} &
+KinGUI & \Rpackage{kinfit} & KinGUI & \Rpackage{kinfit} \\
+\midrule
+\input{R2_comparison}
+\bottomrule
+\end{tabular}
+\end{table}
+
+The comparison shows that whenever the comparison was possible, the $R^2$
+value calculated by the \Rpackage{kinfit} package was equal to the model
+efficiency calculated by KinGUI, both rounded to four digits.
+
\section{Conclusion}
The \Rpackage{kinfit} package for \RR{} gives access to the possibility to

Contact - Imprint