Description Usage Arguments Value Mock vital data Missing data References Examples
View source: R/estimate_beta_S.R
estimate_beta_S()
applies the S method (see References)
to estimate the timevarying transmission rate
β(t)
from time series of reported incidence, births, and
natural mortality, observed at equally spaced time points
t_{k} = t_{0}+kΔt
(for k = 0,...,n),
where
Δt
denotes the observation interval.
1  estimate_beta_S(df = data.frame(), par_list = list())

df 
A data frame with numeric columns:

par_list 
A list containing:

A data frame with numeric columns:
t
Time. Identical to df$t
.
C
Reported incidence, imputed. Identical to df$C
,
except with missing values and zeros imputed (see Details).
Z
Incidence. Z[i]
is the estimated
number of infections between times t[i1]
and t[i]
.
B
Births, imputed. Identical to df$B
(if supplied),
except with missing values imputed (see Details).
mu
Natural mortality rate, imputed. Identical to df$mu
(if supplied), except with missing values imputed (see Details).
S
Number of susceptibles. S[i]
is the estimated
number of susceptibles at time t[i]
.
I
Number of infecteds. I[i]
is the estimated
number of infecteds at time t[i]
.
beta
Transmission rate. beta[i]
is the estimated
transmission rate at time t[i]
expressed per unit
Δt
per susceptible per infected.
It possesses par_list
as an attribute.
If df$B
is undefined in the function call, then df$B[i]
gets the value with(par_list, nu * hatN0 * 1)
for all i
.
If df$mu
is undefined the function call, then df$mu[i]
gets the value with(par_list, mu)
for all i
.
Missing values in df[, c("C", "B", "mu")]
are not tolerated
by the S method. They are imputed via linear interpolation
between observed values. If there are no observations before
the first missing value, then complete imputation is impossible.
In this case, the S method may fail: columns S
and beta
in
the output may be filled with NA
.
Zeros in df$C
cause dividebyzero errors. To prevent these
errors, zeros are imputed like missing values. If there are
no nonzero observations before the first zero, then complete
imputation is impossible. In this case, the S method may fail,
but only locally: column beta
in the output may contain some
NaN
and Inf
, but give estimates everywhere else.
deJonge MS, Jagan M, Krylova O, Earn DJD. Fast estimation of timevarying transmission rates for infectious diseases.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33  # Simulate a reported incidence time series using
# a seasonally forced transmission rate
par_list < make_par_list(dt_weeks = 1, epsilon = 0.5, prep = 0.5)
df < make_data(
par_list = par_list,
n = 20 * 365 / 7, # 20 years is ~1042 weeks
with_dem_stoch = TRUE,
seed = 5
)
head(df)
# Estimate incidence, susceptibles, infecteds,
# and the seasonally forced transmission rate
df_S < estimate_beta_S(df, par_list)
head(df_S)
# Fit a smooth loess curve to the transmission rate
# time series
loess_fit < loess(
formula = beta ~ t,
data = df_S,
span = 65 / nrow(df_S),
degree = 2,
na.action = "na.exclude"
)
df_S$beta_loess < predict(loess_fit)
# Inspect
df_S$t_years < df$t_years
plot(S ~ t_years, df, type = "l", ylim = c(43, 58) * 1e03)
lines(S ~ t_years, df_S, col = "red")
plot(beta ~ t_years, df, type = "l", ylim = c(0.95, 1.25) * 1e05)
lines(beta_loess ~ t_years, df_S, col = "red")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.