require(stats); require(graphics)
data(posneg_data)
modpar(posneg_data$age, posneg_data$mass) #create pnmodelparams for fixed parameters
plot(mass ~ age, data = posneg_data, subset = id == "1",
xlab = "Chick age (day)", las = 1,
ylab = "Chick mass (g)",
main = "posneg_data data and fitted curve (Chick #1 only)")
fm1 <- nls(mass ~ SSposnegRichards(age,Asym=Asym,K=K,Infl=Infl, RAsym=RAsym,
Rk=Rk,Ri=Ri,modno=22),
data = posneg_data, subset = id == "1")
age <- seq(0, 166, length.out = 101)
lines(age, predict(fm1, list(age = age)))
Run the code above in your browser using DataLab