data(metamitron)
#Fit nls grouped model
modNlin <- nls(Conc ~ A[Herbicide] * exp(-k[Herbicide] * Time),
start=list(A=rep(100, 4), k=rep(0.06, 4)),
data=metamitron)
summary(modNlin)
# Compare parameters
funList <- list(~k1 - k2, ~k1 - k3, ~k1 - k4)
gnlht(modNlin, funList)
# Combine parameters
funList <- list(~ -log(0.5)/k1, ~ -log(0.5)/k2,
~ -log(0.5)/k3, ~ -log(0.5)/k4)
gnlht(modNlin, funList)
# Combine more flexibly
funList <- list(~ -log(prop)/k1, ~ -log(prop)/k2,
~ -log(prop)/k3, ~ -log(prop)/k4)
gnlht(modNlin, funList, const = data.frame(prop = 0.5))
funList <- list(~ -log(prop)/k1, ~ -log(prop)/k2,
~ -log(prop)/k3, ~ -log(prop)/k4)
gnlht(modNlin, funList, const = data.frame(prop = c(0.7, 0.5, 0.3)))
# Other possibilities
funList <- list(~ (k2 - k1)/(k1 * k2) * log(prop),
~ (k3 - k1)/(k1 * k3) * log(prop),
~ (k4 - k1)/(k1 * k4) * log(prop))
gnlht(modNlin, funList, const = data.frame(prop = c(0.7, 0.5, 0.3)))
# Predictions
funList <- list(~ A1 * exp (- k1 * Time), ~ A2 * exp (- k2 * Time),
~ A3 * exp (- k3 * Time), ~ A4 * exp (- k4 * Time))
propdF <- data.frame(Time = seq(0, 67, 1))
func <- funList
const <- propdF
pred <- gnlht(modNlin, funList, const = propdF)
head(pred)
tail(pred)
Run the code above in your browser using DataLab