aboutsummaryrefslogtreecommitdiff
path: root/R/mkinerrmin.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2016-11-17 18:14:32 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2016-11-17 18:23:31 +0100
commitf3f415520c89f9d8526bf6fadc862ebd44be220d (patch)
treee80d26e3b4f56ebe872888bed8f01a21d49b7ff4 /R/mkinerrmin.R
parentf52fffd9eab13b7902bf767dd9cd7f0e7abf8069 (diff)
Remove trailing whitespace, clean headers
Also ignore test.R in the top level directory, as it is not meant to be public
Diffstat (limited to 'R/mkinerrmin.R')
-rw-r--r--R/mkinerrmin.R14
1 files changed, 7 insertions, 7 deletions
diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R
index 6103dd1d..b361c466 100644
--- a/R/mkinerrmin.R
+++ b/R/mkinerrmin.R
@@ -24,7 +24,7 @@ mkinerrmin <- function(fit, alpha = 0.05)
kinerrmin <- function(errdata, n.parms) {
means.mean <- mean(errdata$value_mean, na.rm = TRUE)
df = length(errdata$value_mean) - n.parms
-
+
err.min <- sqrt((1 / qchisq(1 - alpha, df)) *
sum((errdata$value_mean - errdata$value_pred)^2)/(means.mean^2))
@@ -32,12 +32,12 @@ mkinerrmin <- function(fit, alpha = 0.05)
}
means <- aggregate(value ~ time + name, data = fit$observed, mean, na.rm=TRUE)
- errdata <- merge(means, fit$predicted, by = c("time", "name"),
+ errdata <- merge(means, fit$predicted, by = c("time", "name"),
suffixes = c("_mean", "_pred"))
errdata <- errdata[order(errdata$time, errdata$name), ]
# Remove values at time zero for variables whose value for state.ini is fixed,
- # as these will not have any effect in the optimization and should therefore not
+ # as these will not have any effect in the optimization and should therefore not
# be counted as degrees of freedom.
fixed_initials = gsub("_0$", "", rownames(subset(fit$fixed, type = "state")))
errdata <- subset(errdata, !(time == 0 & name %in% fixed_initials))
@@ -59,10 +59,10 @@ mkinerrmin <- function(fit, alpha = 0.05)
# Rate constants and IORE exponents are attributed to the source variable
n.k.optim <- length(grep(paste("^k", obs_var, sep="_"), names(parms.optim)))
- n.k.optim <- n.k.optim + length(grep(paste("^log_k", obs_var, sep="_"),
+ n.k.optim <- n.k.optim + length(grep(paste("^log_k", obs_var, sep="_"),
names(parms.optim)))
n.k__iore.optim <- length(grep(paste("^k__iore", obs_var, sep="_"), names(parms.optim)))
- n.k__iore.optim <- n.k__iore.optim + length(grep(paste("^log_k__iore", obs_var,
+ n.k__iore.optim <- n.k__iore.optim + length(grep(paste("^log_k__iore", obs_var,
sep = "_"),
names(parms.optim)))
@@ -87,8 +87,8 @@ mkinerrmin <- function(fit, alpha = 0.05)
# FOMC, DFOP and HS parameters are only counted if we are looking at the
# first variable in the model which is always the source variable
if (obs_var == fit$obs_vars[[1]]) {
- special_parms = c("alpha", "log_alpha", "beta", "log_beta",
- "k1", "log_k1", "k2", "log_k2",
+ special_parms = c("alpha", "log_alpha", "beta", "log_beta",
+ "k1", "log_k1", "k2", "log_k2",
"g", "g_ilr", "tb", "log_tb")
n.optim <- n.optim + length(intersect(special_parms, names(parms.optim)))
}

Contact - Imprint