summaryrefslogtreecommitdiff
path: root/R/kinerrmin.R
blob: 8ce30a38544d8a6d52e835a9f8f8d107b1b3ae56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
kinerrmin <- function(kinfits, kinmodel = "SFO", alpha = 0.05)
{
	m = kinfits[[kinmodel]]

	kindata <- data.frame(t = kinfits[[kinmodel]]$model$t, 
		parent = kinfits[[kinmodel]]$model$parent)
        kindata.means <- aggregate(kindata, list(kindata$t), mean)
	kindata.means.mean <- mean(kindata.means$parent, na.rm=TRUE)

	n.parms = length(coef(m))
	df = length(kindata.means$parent) - n.parms
	kindata.means$est <- predict(m, kindata.means)

	f <- function(err)
	{
		(sum((kindata.means$parent - kindata.means$est)^2/((err*kindata.means.mean)^2)) - 
		 qchisq(1 - alpha,df))^2
	}
	err.min <- optimize(f, c(0.01,0.9))$minimum
	return(err.min)
}

Contact - Imprint