Ajuste em lote de Natural Splines e Regressão Não Linear
#-----------------------------------------------------------------------
# Ajustar o Natural Splines e regressão não linear por grupo para
# estimar as EC 50, 75 e 90.
# Particiona tabela criando uma lista.
tb_split <- tb %>%
mutate(x = log10(dose + 1)) %>%
group_split(isolate)
length(tb_split)
## [1] 60
# Essa função faz todo o trabalho sujo usando natural splines.
main_ns <- function(tb, plots = FALSE) {
condition <- all(is.element(c("isolate", "growth", "x"),
names(tb)))
if (!condition) {
stop("Variables doesn't have the expected names")
}
if (plots) {
plot(growth ~ x, data = tb)
Sys.sleep(1)
}
# Ajuste o modelo usando Natural Splines.
m0 <- lm(growth ~ splines::ns(x, df = 3),
data = tb)
# Modelo de médias.
m_means <- lm(growth ~ factor(x),
data = tb)
# Aplica o teste da falta de ajuste.
lof_test <- anova(m_means, m0)[2, "Pr(>F)"]
if (lof_test < 0.01) {
# Valores únicos da variável independente.
unique_x <- unique(tb$x)
# Em caso de rejeição, tomar o melhor ajuste removendo uma dose.
fits <- vector(mode = "list", length = length(unique_x))
fit_f <- numeric(length(unique_x))
u <- 1
for (j in unique_x) {
m1 <- lm(growth ~ splines::ns(x, df = 3),
data = tb, subset = x != j)
m_means <- update(m1, formula = . ~ factor(x))
fit_f[u] <- anova(m_means, m1)[2, "F"]
fits[[u]] <- m1
u <- u + 1
}
m0 <- fits[[which.min(fit_f)]]
}
# Predição na concentração 0.
y0 <- predict(m0, newdata = list(x = 0))
fracs <- c(0.5, 0.75, 0.9)
y0_fracs <- y0 * fracs
if (plots) {
plot(growth ~ x, data = tb[rownames(m0$model), ])
curve(predict(m0, newdata = list(x = x)),
add = TRUE,
col = "red")
points(x = 0, y = y0, col = "red", pch = 19)
abline(h = y0_fracs, lty = 2, col = "red")
Sys.sleep(1)
}
# Determina a EC50 por solução numérica de raíz de função.
ecs <-
sapply(y0_fracs,
FUN = function(y0_frac) {
xmax <- max(tb[rownames(m0$model), "x"])
root <- try({
uniroot(interval = c(0, 1),
check.conv = FALSE,
extendInt = "downX",
f = function(x) {
predict(m0, newdata = list(x = x)) -
y0_frac
})
})
# Calcula a EC50 na escala original.
ecs <- ifelse(class(root) != "try-error",
root$root,
NA_real_)
return(ecs)
})
if (plots) {
plot(growth ~ x,
data = tb[rownames(m0$model), ])
curve(predict(m0, newdata = list(x = x)),
add = TRUE,
col = "red")
abline(h = y0_fracs, lty = 2, col = "red")
abline(v = ecs, lty = 2, col = "red")
Sys.sleep(1)
}
# Retorno da função.
ret <- list(isolate = tb$isolate[1],
model = m0,
ecs = ecs,
excluded = ifelse(exists("fit_f"),
unique_x[which.min(fit_f)],
NA_real_))
return(ret)
}
# main_ns(tb_split[[1]], plots = TRUE)
# Essa função faz todo o trabalho sujo usando regressão não linear.
main_nls <- function(tb, plots = FALSE) {
condition <- all(is.element(c("isolate", "growth", "x"),
names(tb)))
if (!condition) {
stop("Variables doesn't have the expected names")
}
if (plots) {
plot(growth ~ x, data = tb)
Sys.sleep(1)
}
# Ajuste o modelo usando Natural Splines.
m0 <- try(nls(growth ~ SSfpl(x, sup, inf, xmid, scal),
data = tb))
# Modelo de médias.
m_means <- lm(growth ~ factor(x),
data = tb)
# Aplica o teste da falta de ajuste.
if (class(m0) != "try-error") {
lof_test <- anova(m0, m_means)[2, "Pr(>F)"]
}
if (class(m0) == "try-error" || lof_test < 0.01) {
# Valores únicos da variável independente.
unique_x <- unique(tb$x)
# Em caso de rejeição, tomar o melhor ajuste removendo uma dose.
fits <- vector(mode = "list", length = length(unique_x))
fit_f <- numeric(length(unique_x))
u <- 1
for (j in unique_x) {
j <- unique_x[4]
m1 <- try(nls(growth ~ SSfpl(x, sup, inf, xmid, scal),
data = tb,
subset = x != j))
if (class(m1) == "try-error") {
fit_f[u] <- NA_real_
fits[[u]] <- NULL
} else {
m_means <- lm(growth ~ factor(x),
data = tb,
subset = x != j)
fit_f[u] <- anova(m1, m_means)[2, "F value"]
fits[[u]] <- m1
}
u <- u + 1
}
wm <- which.min(fit_f)
if (length(wm)) {
m0 <- fits[[wm]]
}
}
if (class(m0) == "try-error") {
warning("Nenhum ajuste foi conseguido.")
ret <- list(isolate = tb$isolate[1],
model = NULL,
ecs = rep(NA_real_, 3),
excluded = NA_real_)
return(ret)
}
# Predição na concentração 0.
y0 <- predict(m0, newdata = list(x = 0))
fracs <- c(0.5, 0.75, 0.9)
y0_fracs <- y0 * fracs
if (plots) {
plot(growth ~ x, data = eval(m0$data))
curve(predict(m0, newdata = list(x = x)),
add = TRUE,
col = "red")
points(x = 0, y = y0, col = "red", pch = 19)
abline(h = y0_fracs, lty = 2, col = "red")
Sys.sleep(1)
}
# Determina a EC50 por solução numérica de raíz de função.
ecs <-
sapply(y0_fracs,
FUN = function(y0_frac) {
# xmax <- max(tb[rownames(m0$model), "x"])
root <- try({
uniroot(interval = c(0, 1),
check.conv = FALSE,
extendInt = "downX",
f = function(x) {
predict(m0, newdata = list(x = x)) -
y0_frac
})
})
# Calcula a EC50 na escala original.
ecs <- ifelse(class(root) != "try-error",
root$root,
NA_real_)
return(ecs)
})
if (plots) {
plot(growth ~ x,
data = eval(m0$data))
curve(predict(m0, newdata = list(x = x)),
add = TRUE,
col = "red")
abline(h = y0_fracs, lty = 2, col = "red")
abline(v = ecs, lty = 2, col = "red")
Sys.sleep(1)
}
# Retorno da função.
ret <- list(isolate = tb$isolate[1],
model = m0,
ecs = ecs,
excluded = ifelse(exists("fit_f"),
unique_x[which.min(fit_f)],
NA_real_))
return(ret)
}
# main_nls(tb_split[[8]], plots = TRUE)
# Aplica para todos os isolados usando natural splines.
results_ns <- map(tb_split,
main_ns,
plots = FALSE)
## Error in uniroot(interval = c(0, 1), check.conv = FALSE, extendInt = "downX", :
## no sign change found in 1000 iterations
## Error in uniroot(interval = c(0, 1), check.conv = FALSE, extendInt = "downX", :
## no sign change found in 1000 iterations
## Error in uniroot(interval = c(0, 1), check.conv = FALSE, extendInt = "downX", :
## no sign change found in 1000 iterations
length(results_ns)
## [1] 60
# Aplica para todos os isolados usando regressão não linear.
results_nls <- map(tb_split,
main_nls,
plots = FALSE)
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## step factor 0.000488281 reduced below 'minFactor' of 0.000976562
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
## Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
## Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
## Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
## Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
## Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in uniroot(interval = c(0, 1), check.conv = FALSE, extendInt = "downX", :
## no sign change found in 1000 iterations
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## number of iterations exceeded maximum of 50
## Error in uniroot(interval = c(0, 1), check.conv = FALSE, extendInt = "downX", :
## no sign change found in 1000 iterations
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
## Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, :
## singular gradient
length(results_nls)
## [1] 60