Closed SimonShamusRiley closed 9 months ago
@SimonShamusRiley Sorry for the delay. I'm just now looking at this. The error is because the function returns NA/NaNs and in an effort to summarize the results the function 'quantile' fails. In my opinion, you are fitting a function that has too many parameters given the structure of the data. The 'intervals' show that they are not well estimated. For example, the simple exponential - plateau fits the data better.
me1 <- nls(Log ~ SSexpf(DayNum, a, c), data = microbe)
me2 <- nls(Log ~ SSexpfp(DayNum, a, c, xs), data = microbe)
ggplot(data = microbe,
aes(DayNum, Log)) + geom_point() +
geom_line(aes(y = fitted(me1), color = "exp")) +
geom_line(aes(y = fitted(me2), color = "exp-p"))
@SimonShamusRiley Bootstrapping is a better option in this case
### Bootstrapping
microb_bt <- boot_gnls(weibull_repar, fitted)
prds <- summary_simulate(t(na.omit(microb_bt$t)))
microbeA <- cbind(microbe, prds)
ggplot(data = microbeA,
aes(DayNum, Log)) +
geom_point() +
geom_line(aes(y = fitted(weibull_repar))) +
geom_ribbon(aes(ymin = Q2.5, ymax = Q97.5), alpha = 0.2)
I'm closing this but feel free to open a new issue
I am sometimes, but not always, getting a strange error when attempting to calculate confidence intervals using
predict_gnls()
. In the example which follows, there are measurements (log scale) of the initial microbial population (= Phase1), then again following a first treatment (= Phase2) and then again daily over a period of 5 days following a second treatment (= Phase3). My model includes dummy variables to encode the effects of the treatments 1 and 2, and a re-parameterized Weibull to model subsequent change over time. The model fits without warnings/errors, butpredict_gnls()
fails:Debugging indicates the issue appears somewhere on or around line 166 of predict_nlme.R, but that was as far as I got. I'm running version 1.5 of the package on R 4.1.3. Oddly, the issue doesn't occur with other, similar data sets even using the same model, so I'm at a loss as to what the issue is. Any help you could provide would be much appreciated. Thanks in advance.