Description Usage Arguments Details Value Warning Note Author(s) References Examples
Package to perform non-linear regression in data on the number of daily new cases and daily new deaths of COVID-19 and other epidemics to the 4-parameters Weibull distribution using Metropolis-Markov Chain-Monte Carlo Simulations (MCMC), as described in Moreau, 2021
1 2 |
x |
Vector: time data (may be date/time or numeric) |
y |
Vector: observed/measure event |
shape |
Starting value for Weibull's shape parameters. If it is NA, weibull4.fit will try to calculate it from x and y data. |
scale |
Starting value for Weibull's scale parameters. If it is NA, weibull4.fit will try to calculate it from x and y data. |
loc |
Starting value for Weibull's location parameters. If it is NA, weibull4.fit will try to calculate it from x and y data. |
area |
Starting value for Weibull's area parameters or the area under the PDF curve. If it is NA, weibull4.fit will try to calculate it from x and y data. |
shape2 |
Starting value for the shape parameters of the second mode of the Weibull's distribution. If it is NA, weibull4.fit will try to calculate it from x and y data. It works only if modes=2. |
scale2 |
Starting value for the scale parameters of the second mode of the Weibull's distribution. If it is NA, weibull4.fit will try to calculate it from x and y data. It works only if modes=2. |
loc2 |
Starting value for the location parameters of the second mode of the Weibull's distribution. If it is NA, weibull4.fit will try to calculate it from x and y data. It works only if modes=2. |
area2 |
Starting value for the area parameters of the second mode of the Weibull's distribution. If it is NA, weibull4.fit will try to calculate it from x and y data. It works only if modes=2. |
iter |
Number of iterations to perform Metropolis-MCMC. |
modes |
Sets whether data may be fit with unimodal or bimodal Weibull distribution. This option was implemented to fit data feom the second wave of infections and deaths for COVID-19. Use modes=1 for unimodal distribution (single peak) and modes=2 for bimodal distribution (two peaks). |
xmax |
Forecast date to be calculated after x data. It must be in the same format than x. |
This package was specially built to fit COVID-19 data on the number of daily new cases and deaths in countries. So x must be integer. Alternatively, Date format is allowed
LIST containning:
Fit data |
Matrix with x and y fitted data |
Estimates |
Matrix containning shape, scale, location, area and SD of the MEtropolis-MCMC in the row 1; and standard deviation for each parameter in the row 2 |
Markov chains |
Matrix containning the Markov chains for shape, scale, location, area and SD parameters |
This package is a secondary product of the reffered science paper. Please, note that there is no warrants or professional support on its use
Comments, suggestions and doubts must be sent to vitorhmc@ufba.br
Vitor Hugo Moreau, Ph.D
MOREAU, V. H. (2021) Forecast projections of COVID-19 pandemic by Weibull distribution from daily new cases and deaths data, Model Assisted Statistics and Applications. in press. Part of the MCMC code came from the Florian Hartig blog: "https://theoreticalecology.wordpress.com/2010/09/17/metropolis-hastings-mcmc-in-r/"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Perform non-linear curve fitting with World's data for daily new deaths
## of COVID-19
## Examples below are with low number of iterations (1000), because of CRAN rules limitations.
## They will possibily give poor results. For best results set iter=10000.
fit <- weibull4(US_COVID$date, US_COVID$new_deaths, iter=1000)
plot(US_COVID$date, US_COVID$new_deaths, ylab="US' daily new deaths", xlab="Date")
lines(fit[[1]][,1], fit[[1]][,2], col="red")
## Perform non-linear curve fitting with Canada's data for daily new cases of
## COVID-19 using two unimodal Weibull distribution, with split date on Aug, ## 1st
fit <- weibull4(Canada_COVID$date, Canada_COVID$new_cases, modes=1, iter=1000)
plot(Canada_COVID$date, Canada_COVID$new_cases, ylab="Canada's daily new cases", xlab="Date")
lines(fit[[1]][,1], fit[[1]][,2], col="red")
## Perform non-linear curve fitting with Brazil's data for daily new deaths of
## COVID-19 using a single bimodal Weibull distribution
fit <- weibull4(Brazil_COVID$date, Brazil_COVID$new_deaths, modes=2, iter=1000)
plot(Brazil_COVID$date, Brazil_COVID$new_deaths, ylab="Brazil's daily new deaths", xlab="Date")
lines(fit[[1]][,1], fit[[1]][,2], col="red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.