Type: | Package |
Title: | Non Linear Growth Models |
Version: | 1.0 |
Date: | 2022-11-25 |
Author: | Michail Tsagris [aut, cre], Nikolaos Pandis [aut] |
Maintainer: | Michail Tsagris <mtsagris@uoc.gr> |
Depends: | R (≥ 4.0) |
Imports: | ggplot2, Rfast, Rfast2, stats |
Description: | Six growth models are fitted using non-linear least squares. These are the Richards, the 3, 4 and 5 parameter logistic, the Gompetz and the Weibull growth models. Reference: Reddy T., Shkedy Z., van Rensburg C. J., Mwambi H., Debba P., Zuma K. and Manda, S. (2021). "Short-term real-time prediction of total number of reported COVID-19 cases and deaths in South Africa: a data driven approach". BMC medical research methodology, 21(1), 1-11. <doi:10.1186/s12874-020-01165-x>. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
NeedsCompilation: | no |
Packaged: | 2022-11-25 14:36:41 UTC; Michail |
Repository: | CRAN |
Date/Publication: | 2022-11-28 14:40:02 UTC |
This is an R package that fits 6 non linear growth models.
Description
Six growth models are fitted using non-linear least squares. The relevant reference is: Reddy T., Shkedy Z., van Rensburg C. J., Mwambi H., Debba P., Zuma K. and Manda, S. (2021). Short-term real-time prediction of total number of reported COVID-19 cases and deaths in South Africa: a data driven approach. BMC Medical Research methodology, 21(1): 1–11. <doi:10.1186/s12874-020-01165-x>.
Details
Package: | nlgmcr Type: | Package |
Version: | 1.0 | |
Date: | 2021-11-25 | |
License: | GPL-2 | |
Maintainers
Michail Tsagris mtsagris@uoc.gr.
Note
Acknowledgments:
Author(s)
Michail Tsagris mtsagris@uoc.gr and Nikolaos Pandis npandis@yahoo.com.
References
Reddy T., Shkedy Z., van Rensburg C. J., Mwambi H., Debba P., Zuma K. and Manda, S. (2021). Short-term real-time prediction of total number of reported COVID-19 cases and deaths in South Africa: a data driven approach. BMC medical Research Methodology, 21(1): 1–11.
Non-linear growth models
Description
Non-linear growth models.
Usage
nlgm(y, ti, type, ini, ti.ahead = NULL)
Arguments
y |
A vector with the cumulative number of cases. |
ti |
A vector with the time, e.g. days. |
ini |
A vector with the initial values. The length varies according to the type of growth model. |
type |
The type of the growth model. "richards", "3logistic", "4logistic", "5logistic", "gompertz" or "weibull". See Reddy et al. (2021) for more information. |
ti.ahead |
If you want to make predictions for a number of days ahead, provide the number of days, a single number. |
Details
Non-linear growth curves are fitted using least squares.
Value
A list including:
mod |
The object as returned by the function |
param |
A vector with the parameters of the chosen model. |
fit |
The fitted values. |
pred |
The future predictions if values for the argument "ti.ahead" were given, otherwise this is NULL. |
Author(s)
Michail Tsagris and Nikolaos Pandis.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr and Nikolaos Pandis npandis@yahoo.com.
References
Reddy T., Shkedy Z., van Rensburg C. J., Mwambi H., Debba P., Zuma K. and Manda, S. (2021). Short-term real-time prediction of total number of reported COVID-19 cases and deaths in South Africa: a data driven approach. BMC medical research methodology, 21(1), 1-11.
See Also
Examples
## Data on Covid 19 for the first 96 days of Belgium
y <- c( 19, 38, 72, 125, 206, 316, 343, 407, 501, 600, 774, 1024, 1362, 1541, 1755, 2142,
2564, 3098, 3811, 4473, 4942, 5428, 6756, 7951, 9150, 10513, 12031, 12875, 13558,
15296, 16977, 18493, 19971, 21665, 22587, 23252, 25186, 26701, 28299, 30538, 32874,
33903, 34427, 34964, 36524, 38157, 39831, 41225, 41947, 42390, 43666, 44936, 45713,
46689, 47500, 47888, 48093, 48848, 49417, 49939, 50525, 50762, 51048, 51188, 51858,
52404, 52956, 53398, 53881, 54121, 54239, 54715, 55110, 55431, 55736, 56082, 56229,
56310, 56627, 56919, 57304, 57374, 57622, 57745, 57820, 58134, 58336, 58518, 58689,
58854, 58915, 58964, 59023, 59204, 59363, 59535 )
ti <- 1:96
## Apply the 4-parameter logistic model
mod1 <- nlgm(y, ti, type = "4logistic", ini = c(60000, 1, 1, 35) )
## predict the cases 10 days ahead
mod2 <- nlgm(y, ti, type = "4logistic", ini = c(60000, 1, 1, 35), ti.ahead = 10 )
Parametric bootstrap prediction intervals
Description
Parametric bootstrap prediction intervals.
Usage
boot.pred(mod, type, ti, ti.ahead = 10, B = 1000, conf = 0.95, seed = NULL)
Arguments
mod |
The "nls" object of the |
type |
The type of the growth model. "richards", "3logistic", "4logistic", "5logistic", "gompertz" or "weibull". See Reddy et al. (2021) for more information. |
ti |
A vector with the time, e.g. days. |
ti.ahead |
The future time points. |
B |
The number of boostrap samples to draw. These samples are drawn from a Poisson distribution. |
conf |
The prediction level, set to 95% by default. |
seed |
Provide a seed number if you want, otherwise leave it NULL. |
Details
Non-linear growth curves are fitted using least squares. Based on the model a parametric bootstrap is applied in order to construct prediction intervals. The fitted values act as the mean from which Poisson samples are drawn and the nlgm is fitted. Using this fitted model, the predicted number of cumulative cases, at the selected number of days ahead, are calculated. This process is repated B times and in the end the prediction interval is computed by returning the tails of this bootstrap predicted values distribution.
Value
A list including:
est |
A column with 3 columns, the mean of the bootstrap based preditions and the prediction interval. |
pred |
A matrix with B columns. Each column represents a bootstrap based set of prediction values. |
Author(s)
Michail Tsagris and Nikolaos Pandis.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr and Nikolaos Pandis npandis@yahoo.com.
References
Reddy T., Shkedy Z., van Rensburg C. J., Mwambi H., Debba P., Zuma K. and Manda, S. (2021). Short-term real-time prediction of total number of reported COVID-19 cases and deaths in South Africa: a data driven approach. BMC medical research methodology, 21(1), 1-11.
See Also
Examples
## Data on the 96 first days of Belgium
y <- c( 19, 38, 72, 125, 206, 316, 343, 407, 501, 600, 774, 1024, 1362, 1541, 1755, 2142,
2564, 3098, 3811, 4473, 4942, 5428, 6756, 7951, 9150, 10513, 12031, 12875, 13558,
15296, 16977, 18493, 19971, 21665, 22587, 23252, 25186, 26701, 28299, 30538, 32874,
33903, 34427, 34964, 36524, 38157, 39831, 41225, 41947, 42390, 43666, 44936, 45713,
46689, 47500, 47888, 48093, 48848, 49417, 49939, 50525, 50762, 51048, 51188, 51858,
52404, 52956, 53398, 53881, 54121, 54239, 54715, 55110, 55431, 55736, 56082, 56229,
56310, 56627, 56919, 57304, 57374, 57622, 57745, 57820, 58134, 58336, 58518, 58689,
58854, 58915, 58964, 59023, 59204, 59363, 59535 )
ti <- 1:96
## Apply the 4-parameter logistic model
mod <- nlgm(y, ti, type = "4logistic", ini = c(60000, 1, 1, 35) )
preds <- boot.pred(mod, type = "4logistic", ti = ti, B = 100)
Plot of the fitted values of the non-linear growth models
Description
Plot of the fitted values of the non-linear growth models.
Usage
fit.plot(mat)
Arguments
mat |
A data.frame object with three columns, the observed cumulative cases, the time and the fitted values from a model. The names must be "cases", "ti" and "fit". See the examples below for an illustration. |
Details
The scatter plot of the cumulative cases versus time is plotted. Then, lines with the fitted cases are added.
Value
A scatter plot of the cumulative cases versus time, including lines with the fitted cases.
Author(s)
Nikolaos Pandis and Michail Tsagris.
R implementation and documentation: Nikolaos Pandis npandis@yahoo.com and Michail Tsagris mtsagris@uoc.gr.
References
Reddy T., Shkedy Z., van Rensburg C. J., Mwambi H., Debba P., Zuma K. and Manda, S. (2021). Short-term real-time prediction of total number of reported COVID-19 cases and deaths in South Africa: a data driven approach. BMC medical research methodology, 21(1), 1-11.
See Also
Examples
## Data on the 96 first days of Belgium
y <- c( 19, 38, 72, 125, 206, 316, 343, 407, 501, 600, 774, 1024, 1362, 1541, 1755, 2142,
2564, 3098, 3811, 4473, 4942, 5428, 6756, 7951, 9150, 10513, 12031, 12875, 13558,
15296, 16977, 18493, 19971, 21665, 22587, 23252, 25186, 26701, 28299, 30538, 32874,
33903, 34427, 34964, 36524, 38157, 39831, 41225, 41947, 42390, 43666, 44936, 45713,
46689, 47500, 47888, 48093, 48848, 49417, 49939, 50525, 50762, 51048, 51188, 51858,
52404, 52956, 53398, 53881, 54121, 54239, 54715, 55110, 55431, 55736, 56082, 56229,
56310, 56627, 56919, 57304, 57374, 57622, 57745, 57820, 58134, 58336, 58518, 58689,
58854, 58915, 58964, 59023, 59204, 59363, 59535 )
ti <- 1:96
mod <- nlgm(y, ti, type = "4logistic", ini = c(60000, 1, 1, 35) )
mat <- cbind(y, ti, mod$fit)
colnames(mat) <- c("cases", "ti", "fit")
mat <- as.data.frame(mat)
fit.plot(mat)