I was able to get nls with a coefficient per your initial suggestion to complete with these parameters:
mod.nls.c <- nls(GrowthRate ~ i + c * I(DAY^power),
data = exdata,
start = list(power = -0.01, i = 1.005258, c = 2),
control = nls.control(maxiter = 200))
mod.nls.c |> summary()
Formula: GrowthRate ~ i + c * I(DAY^power)
Parameters:
Estimate Std. Error t value Pr(>|t|)
power -6.285e-01 9.733e-04 -645.7 <2e-16
i 9.898e-01 6.423e-05 15410.8 <2e-16
c 4.587e-01 7.141e-04 642.3 <2e-16
power ***
i ***
c ***
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.03025 on 1064596 degrees of freedom
Number of iterations to convergence: 25
Achieved convergence tolerance: 7.798e-06
But the same issue seems to persist, here's the plot and zoomed in plot:
exdata$PredictionsNLSC <- predict(mod.nls.c)
set.seed(123)
exdata |>
sample_n(200000) |>
ggplot(aes(x = DAY, y = GrowthRate)) +
geom_point(alpha = 0.01, color = 'grey') +
geom_line(aes(x = DAY, y = PredictionsNLSC), color = 'steelblue') +
theme_minimal()
And zoomed in between days 30 and 365:
set.seed(123)
exdata |>
sample_n(200000) |>
filter(DAY >= 30 & DAY <= 365) |>
ggplot(aes(x = DAY, y = GrowthRate)) +
geom_point(alpha = 0.01, color = 'grey') +
geom_line(aes(x = DAY, y = PredictionsNLSC), color = 'steelblue') +
theme_minimal()
Tried a coefficient. Anything else I could try?! Will share some data later too.