### Not currently working on this # library(ggplot2) # # data(Orange) # # tree3 <- subset(Orange, Tree == 3) # # fm0 <- nls(circumference ~ SSlogis(age, Asym, xmid, scal), data = tree3) # # ggplot(data = tree3, aes(x = age, y = circumference)) + # geom_point() + # geom_line(aes(y = fitted(fm0))) # # tree31 <- data.frame(age = c(tree3$age, 1900, 2200, 2400, tree3$age + 3000, # 5000, 5600), # circumference = c(tree3$circumference, # 150, 155, 153, # tree3$circumference + 150, # 300, 305)) # # ggplot(data = tree31, aes(x = age, y = circumference)) + # geom_point() # # getInitial(circumference ~ SSdlogis7(age, y.min, # y.mid, # y.max, # xmid1, scal1, xmid2, scal2), # data = tree31) # # getInitial(circumference ~ SSdlogis4(age, yt, # yd, # xmid, scal), # data = tree31) # # fm1 <- minpack.lm::nlsLM(circumference ~ SSdlogis7(age, y.min, # y.mid, # y.max, # xmid1, # scal1, # xmid2, # scal2), # data = tree31) # # # fm1 <- minpack.lm::nlsLM(circumference ~ SSdlogis4(age, yt, # yd, # xmid, scal), # data = tree31, # control = list(maxiter = 1000)) # # ggplot(data = tree31, aes(x = age, y = circumference)) + # geom_point() + # geom_line(aes(y = fitted(fm1))) # # grd <- expand.grid(yt = seq(0, 300, length.out = 10), # yd = seq(0, 300, length.out = 10), # xmid = seq(0, 5000, length.out = 10), # scal = seq(0, 1000, length.out = 10)) # # fm.bf <- nls2(circumference ~ dlogis4(age, yt, # yd, # xmid, scal), # start = grd, # algorithm = "brute", # data = tree31) # # xx <- 1:5000 # yy <- dlogis4(xx, yt = 150, yd = 150, xmid = 2500, scal = 400) # # plot(xx, yy) # # # xx <- 1:6000 # yy <- dlogis7(xx, y.min = 30, y.mid = 150, y.max = 300, # xmid1 = 1500, scal1 = 300, xmid2 = 4200, scal2 = 300) # # plot(xx, yy) # # ggplot() + # geom_point(data = tree31, aes(x = age, y = circumference)) + # geom_line(aes(x = xx, y = yy)) # # fm1 <- minpack.lm::nlsLM(circumference ~ dlogis7(age, y.min, # y.mid, # y.max, # xmid1, # scal1, # xmid2, # scal2), # data = tree31, # start = c(y.min = 0, y.mid = 150, y.max = 300, # xmid1 = 700, scal1 = 300, # xmid2 = 4200, scal2 = 200))