This is data set of Covid-19 cases from New York State in January. This data set starts on January 7th, the highest number of recorded cases and ends on the 31st totaling 25 days. This particular data was picked to simulate an example of half-life. If an object has an half-life that means that object has a set time where it dwindle downs to half of its initial value.
This data was collected from the official website of New York State https://coronavirus.health.ny.gov/positive-tests-over-time-region-and-county
# data on covid-19 cases from the 7th to the 31st
date <- seq(1, 25, 1)
cases <- c(90.1, 79.8, 54.7, 48.7, 58.7, 60.3, 49.0, 47.8, 51.2, 26.8, 22.3, 23.3, 30.6, 28.3, 27.6, 19.2, 12.3, 12.5, 16.5, 17.3, 13.6, 12.3, 8.78, 5.12, 7.12)
y <- 90*exp(-0.1*date)
#plots the data as a graph
plot(date, cases, main = "Covid-19 Cases January 2022",
xlab = 'Days', ylab = 'Cases per 1k',
xlim = c(1, 20), ylim = c(0, 100))
lines(date, y)
yfit <- 0
library(nls2)
## Loading required package: proto
library(subplex)
yfit <- nls(cases ~ alpha*exp(-k*date),
start = c(alpha=90 , k=0.1))
# alpha is estimated initial quantity of covid-19 cases
# k is the estimated decay constant
summary(yfit)
##
## Formula: cases ~ alpha * exp(-k * date)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## alpha 91.45143 4.88308 18.73 2.01e-15 ***
## k 0.09606 0.00739 13.00 4.41e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.828 on 23 degrees of freedom
##
## Number of iterations to convergence: 2
## Achieved convergence tolerance: 8.327e-06
lines(date, predict(yfit), col = 'red')
The data here roughly displays the half-life of coronavirus-19 cases in New York in January 2022. Roughly every 6-7 days the number of Covid-19 cases drop by half. The decay constant or k value is 0.09606 after estimating 0.1 as the initial k value. The standard error estimate for k is 0.00739. The red line is the best fit using nonlinear least-square estimate.