I wish to fit multiple nls functions using a group_by from the dplyr package but I am unsure how I can pass multiple starting values. Let's take a simpler example (see ?nls for the inspiration).
DNase1 <- subset(DNase, Run == 1)
modelDNase1 <- DNase1 %>%
do(model = nls(density ~ 1/(1 + exp((xmid - log(conc))/scal)),
data = .,
start = list(xmid = 0, scal = 1),
algorithm = "plinear"))
So here I am fitting a single model. But what if I want to extend this so I am fitting the following:
DNase$Run <- factor(DNase$Run)
modelDNase <- DNase %>%
group_by(Run) %>%
do(model = nls(density ~ 1/(1 + exp((xmid - log(conc))/scal)),
data = .,
start = list(xmid = 0, scal = 1),
algorithm = "plinear"))
How would I pass on multiple start parameters? Would the purrr package be of any use?