An estimator of the reproduction number (\(R_t\)) using a renewal equation method.

Version: 0.03

Generated: 2022-05-24T22:12:30.960709

Arguments

minWindow

minWindow - the smallest amount of data considered in estimating the growth rate, 4 is a sensible default unless you want bang up to date estimate. - (java expects a int)

maxWindow

maxWindow - the largest amount of data considered in estimating the growth rate, 14 is a sensible amount. - (java expects a int)

Details

The renewal equation method depends on a time series of infections, and on the infectivity profile - a measure of the probability that a secondary infection occurred on a specific day after the primary case, given a secondary infection occurred. A Bayesian framework is then used to update a prior probabilistic estimate of \(R_t\) on any given day with both information gained from the time series of infections in the epidemic to date and the infectivity profile to produce a posterior estimate of \(R_t\). This is based on the article:<br>

<br>A. GrowthRate, N. M. Ferguson, C. Fraser, and S. Cauchemez, ‘A New Framework and Software to Estimate Time-Varying Reproduction Numbers During Epidemics’, Am J Epidemiol, vol. 178, no. 9, pp. 1505–1512, Nov. 2013, doi: 10.1093/aje/kwt133.<br>

<br> and the implementation of it in the R Library EpiEstim. It assumes that infections (or other type of observation) are a Poisson distributed process and that the reproduction number is a gamma distributed quantity. The estimates of \(R_t\) may be aggregated over a specific "window" to provide a more stable estimate.

Methods

Constructors

Static methods

Instance methods


Method new()

Produces a GrowthRateEstimator that is configured to behave in a sensible fashion, with sane defaults. In that it estimates an initial poisson rate prior from the first entry and returns a fixed window size and aggregates uncertain SI distributions with a random resampling strategy<br><br>

Usage

J = jepidemic::JavaApi$get()
J$GrowthRateEstimator$new(minWindow, maxWindow)
        

Arguments

  • minWindow - the smallest amount of data considered in estimating the growth rate, 4 is a sensible default unless you want bang up to date estimate. - (java expects a int)

  • maxWindow - the largest amount of data considered in estimating the growth rate, 14 is a sensible amount. - (java expects a int)

Returns

R6 GrowthRateEstimator object:

Examples

not available
			


Method strictGrowthRateAndRtEstimator()

Produces a GrowthRateEstimator that will estimate growth rate and $R_t$, with sane defaults. The $R_t$ estimation is done using bootstrapping, and combining the results using a mixture distribution. This will be relatively slow.

Usage

J = jepidemic::JavaApi$get()
J$GrowthRateEstimator$strictGrowthRateAndRtEstimator(minWindow, maxWindow, infectivityProfiles)
        

Arguments

  • minWindow - the smallest amount of data considered in estimating the growth rate - 4 is a ssensible default unless you want bang up to date estimate. - (java expects a int)

  • maxWindow - the largest amount of data considered in estimating the growth rate - 14 is a sensible amount. - (java expects a int)

  • infectivityProfiles - a numeric matrix with each column containing a discrete probability distribution of the serial interval with \(P_(t=0) = 0\) - (java expects a RNumericArray)

Returns

R6 GrowthRateEstimator object: a strict growth rate and \(R_t\) estimator that accounts for uncertainty in the infectivity profile.

Examples

not available
			


Method defaultGrowthRateAndRtEstimator()

Produces a GrowthRateEstimator that will estimate growth rate and $R_t$, with sane defaults. The $R_t$ estimation is done using a single infectivity profile and does not account for infectivity profile uncertainty. This is comparatively fast.<br><br>

Usage

J = jepidemic::JavaApi$get()
J$GrowthRateEstimator$defaultGrowthRateAndRtEstimator(minWindow, maxWindow, initialIncidence)
        

Arguments

  • minWindow - the smallest amount of data considered in estimating the growth rate - 4 is a ssensible default unless you want bang up to date estimate. - (java expects a int)

  • maxWindow - the largest amount of data considered in estimating the growth rate - 14 is a sensible amount. - (java expects a int)

  • initialIncidence - a guess at the initial incidence of the time series - (java expects a double)

Returns

R6 GrowthRateEstimator object: a growth rate and \(R_t\) estimator that does not account for uncertainty in the infectivity profile.

Examples

not available
			


Method defaultGrowthRateEstimator()

Produces a GrowthRateEstimator that will estimate growth rate only, with sane defaults, unless an infectivity profile is lated added<br><br>

Usage

J = jepidemic::JavaApi$get()
J$GrowthRateEstimator$defaultGrowthRateEstimator(minWindow, maxWindow)
        

Arguments

  • minWindow - the smallest amount of data considered in estimating the growth rate - 4 is a ssensible default unless you want bang up to date estimate. - (java expects a int)

  • maxWindow - the largest amount of data considered in estimating the growth rate - 14 is a sensible amount. - (java expects a int)

Returns

R6 GrowthRateEstimator object: a growth rate and \(R_t\) estimator that does not account for uncertainty in the infectivity profile.

Examples

not available
			


Method basicGrowthRateEstimator()

Produces a GrowthRateEstimator that will estimate growth rate only, with sane defaults, and estimating using windows between 4 and 14 days<br><br>

Usage

J = jepidemic::JavaApi$get()
J$GrowthRateEstimator$basicGrowthRateEstimator()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a growth rate and \(R_t\) estimator that does not account for uncertainty in the infectivity profile.

Examples

not available
			


Method withOutputQuantiles()

Allows you to change the quantiles returned by the estimator. The defaults are c(0.025,0.05,0.25,0.5,0.75,0.95,0.975)

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withOutputQuantiles(quantiles)
        

Arguments

  • quantiles the desired quantiles of the output - (java expects a RNumericVector)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method withSaneDefaults()

Provides a sensible baseline configuration for the estimator that involves estimating the poisson rate using the previous timestep's posterior and growth rate estimates. Multiple posterior estimates are combined using a weighted average based on a discretised normal distributed weight with mean of 7 and SD of 4.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withSaneDefaults()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method withInitialIncidence()

Allows configuration of the initial incidence. If this is omitted the initial incidence is guessed from the first entry in the timeseries

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withInitialIncidence(incidence)
        

Arguments

  • incidence - the prior incidence estimate prior to the the beginning of the time series. - (java expects a double)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method withGaussianEstimateWeighting()

Allows configuration of the weighting of estimate combination for the weighted mixture combination. This uses a discretised normal distribution to generate values for the weighting. The weighting is applied to each supported estimate determined by the data window of that estimate. The default value is a mean of 7 and SD of 4

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withGaussianEstimateWeighting(meanTau, sdTau)
        

Arguments

  • meanTau the mean of the normal distribution of weights - (java expects a double)

  • sdTau the sd of the normal distribution of weights - (java expects a double)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method withEstimateWeighting()

Allows configuration of the weighting of estimate combination for the weighted mixture combination. This assumes the weights are given as a vector where the first entry is the weight for an estimate using a data window of 1. The vector should be the same length as the maxWindow parameter used in configuring the GrowthRateEstimator or 14 if the defaults were used.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withEstimateWeighting(weights)
        

Arguments

  • weights - a vector of weights for each data window - (java expects a RNumericVector)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method combineEstimatesWithWeightedMixture()

Sets the estimator to use a weighted mixture to combine estimates based on the length of different data windows, using weights defined by withEstimateWeighting() or withGaussianEstimateWeighting(). If none is set the weighting defaults to a discretised normal distribution with mean of 7 an SD of 4.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$combineEstimatesWithWeightedMixture()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromPreviousPosterior()

Select a prior estimate for the poisson rate by taking the previous posterior and multiplying the SD by a constant factor

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromPreviousPosterior(multiplyingSDby)
        

Arguments

  • multiplyingSDby - factor to multiply SD by. Must be greater than or equal to 1. - (java expects a double)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromScaledPreviousPosterior()

Select a prior estimate for the poisson rate by taking the previous posterior and multiplying the SD by a factor determined by the difference between the t-1 and t-2 incidence. This allows for rapid rate of change to be detected and less weight given to the prior in this situation

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromScaledPreviousPosterior()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromPosteriorAndGrowthRate()

Select a prior estimate for the poisson rate by taking the previous posterior and increasing it by the exponential previous posterior growth rate and multiplying the resulting disctribution by a constant factor. This is a mechanistic prior.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromPosteriorAndGrowthRate(multiplyingSDby)
        

Arguments

  • multiplyingSDby - factor to multiply SD by. Must be greater than or equal to 1. - (java expects a double)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromScaledPosteriorAndGrowthRate()

Select a prior estimate for the poisson rate by taking the previous posterior and increasing it by the exponential previous posterior growth rate and multiplying the resulting disctribution by a factor determined by the change in t-1 and t-2 indidence. This is a mechanistic prior.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromScaledPosteriorAndGrowthRate()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromPosteriorMean()

Select a prior estimate for the poisson rate by taking the previous posterior and constructing a prior with mean and sd both equal to the mean of the previous posterior.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromPosteriorMean()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromPosteriorMeanAndGrowthRate()

Select a prior estimate for the poisson rate by taking the previous posterior and constructing a prior with mean and sd both equal to the mean of the previous posterior plus the growth rate.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromPosteriorMeanAndGrowthRate()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromPosteriorMeanAndCoefVariation()

Select a prior estimate for the poisson rate by taking the previous posterior and constructing a prior with mean and sd both equal to the mean of the previous posterior.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromPosteriorMeanAndCoefVariation(kappa)
        

Arguments

  • kappa - the coefficient of variation of the prior. - (java expects a double)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method priorIncidenceFromPosteriorMeanAndGrowthRateAndCoefVariation()

Select a prior estimate for the poisson rate by taking the previous posterior and constructing a prior with mean and sd both equal to the mean of the previous posterior plus the growth rate.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$priorIncidenceFromPosteriorMeanAndGrowthRateAndCoefVariation(kappa)
        

Arguments

  • kappa - the coefficient of variation of the prior. - (java expects a double)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method useAllPosteriorEstimates()

The posterior estimates for each combination of data window and infectivity profile are all retained and combined

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$useAllPosteriorEstimates()
        

Arguments

  • none

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method usePosteriorEstimatesFromOneWindow()

The posterior estimates for only one data window, but all infectivity profiles, are retained and combined. N.b. the same effect can be achieved by setting the minWindow and maxWindow in the constructor.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$usePosteriorEstimatesFromOneWindow(tau)
        

Arguments

  • tau the window width to retain. - (java expects a int)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method usePosteriorEstimatesWithEnoughData()

The posterior estimates for data windows that include a reasonable amount of data are retained and combined. This suppresses noisy estimates made on a very few data points when incidence is low.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$usePosteriorEstimatesWithEnoughData(sumIncidence)
        

Arguments

  • sumIncidence - the minimum number of cases that must be observed in a data window before the estimate is ignored. - (java expects a int)

Returns

R6 GrowthRateEstimator object: a fluent method

Examples

not available
			


Method withInfectivityProfile()

Configure the estimator with an infectivity profile. At least one profile must be added for an estimate of R_t to be made

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withInfectivityProfile(infectivityProfile, replace)
        

Arguments

  • infectivityProfile - A numeric vector of the daily discrete probability of a secondary infection event occurring given an infected individual. It is assumed that this vector starts at time zero with a probability of zero. - (java expects a RNumericVector)

  • replace - replace the existing infectivity profile with this new one? if false then the profile is added to a list. - (java expects a boolean)

Returns

R6 GrowthRateEstimator object: The estimator itself (a fluent method)

Examples

not available
			


Method withInfectivityProfileMatrix()

Configure the estimator with an infectivity profile by specifying it as a matrix. This will replace all previously set profiles.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$withInfectivityProfileMatrix(infectivityProfiles)
        

Arguments

  • infectivityProfiles - A numeric array of the daily discrete probability of a secondary infection event occurring given an infected individual in each column. It is assumed that this vector starts at time zero with a probability of zero. - (java expects a RNumericArray)

Returns

R6 GrowthRateEstimator object: The estimator itself (a fluent method)

Examples

not available
			


Method estimateGrowthRate()

Estimates growth rate and, if configured with an infectivity profile, \(R_t\) for a one or more timeseries of infections in an epidemic. If the supplied dataframe is grouped it assumes ach grouping is a timeseries

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$estimateGrowthRate(incidence, dateColName, incidenceColName)
        

Arguments

  • incidence - a dataframe containing at least 2 columns (one containing a date, the other a numeric count of cases). The dataframe may be grouped, in which case grouping is preserved, and each group is treated as a seperate time seriesincidenceColName - the name of the incidence column - (java expects a RDataframe)

  • dateColName - the name of the date column - (java expects a String)

  • incidenceColName - the name of the incidence column - (java expects a String)

Returns

RDataframe: a dataframe, containing a summary of the estimates of incidence, growth rate and \(R_t\) with mean, sd, and quantiles for each day.

Examples

not available
			


Method estimateGrowthRateSingle()

Estimates \(R_t\) for a single timeseries of infections in an epidemic.

Usage

J = jepidemic::JavaApi$get()
instance = J$GrowthRateEstimator$new(...);
instance$estimateGrowthRateSingle(incidence, dateColName, incidenceColName)
        

Arguments

  • incidence - a dataframe containing at least 2 columns (one containing a date, the other a numeric count of cases).incidenceColName - the name of the incidence column - (java expects a RDataframe)

  • dateColName - the name of the date column - (java expects a String)

  • incidenceColName - the name of the incidence column - (java expects a String)

Returns

RDataframe: a dataframe, containing either a summary of the estimates of \(R_t\) with mean, sd, and quantiles for each day, or a full breakdown of the component \(R_t\) estimates.

Examples

not available
			

Examples

if (FALSE) { J = jepidemic::JavaApi$get(); instance = J$GrowthRateEstimator$new(minWindow, maxWindow) ## ----------------------------------- ## Method `GrowthRateEstimator$strictGrowthRateAndRtEstimator` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$defaultGrowthRateAndRtEstimator` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$defaultGrowthRateEstimator` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$basicGrowthRateEstimator` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withOutputQuantiles` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withSaneDefaults` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withInitialIncidence` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withGaussianEstimateWeighting` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withEstimateWeighting` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$combineEstimatesWithWeightedMixture` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromPreviousPosterior` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromScaledPreviousPosterior` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromPosteriorAndGrowthRate` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromScaledPosteriorAndGrowthRate` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromPosteriorMean` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromPosteriorMeanAndGrowthRate` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromPosteriorMeanAndCoefVariation` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$priorIncidenceFromPosteriorMeanAndGrowthRateAndCoefVariation` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$useAllPosteriorEstimates` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$usePosteriorEstimatesFromOneWindow` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$usePosteriorEstimatesWithEnoughData` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withInfectivityProfile` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$withInfectivityProfileMatrix` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$estimateGrowthRate` ## ----------------------------------- ## ----------------------------------- ## Method `GrowthRateEstimator$estimateGrowthRateSingle` ## ----------------------------------- }