Skip to content

Quasimultinomial

The quasimultinomial noise model, which corresponds to the high-level Covvfit utilities.
It can be imported as:

from covvfit import quasimultinomial as qm

It has the following capabilities:

covvfit.quasimultinomial.construct_total_loss(ys, ts, ns=1.0, overdispersion=1.0, accept_theta=True, average_loss=False)

Constructs the loss function, suitable e.g., for optimization.

Parameters:

Name Type Description Default
ys list

list of variant proportions for each city. The ith entry should be an array of shape (n_timepoints[i], n_variants)

required
ts list

list of timepoints. The ith entry should be an array of shape (n_timepoints[i],) Note: ts should be appropriately normalized

required
ns float | list[float] | list[jax.Array] | list[list[float]] | jaxFloat[Array, 'cities']

controls the quasimultinomial sample size of each city. It can be: - a single float (sample size is constant across all cities and timepoints) - a sequence of floats, describing one sample size for each city - a list of arrays, with the ith entry having length n_timepoints[i]

1.0
overdispersion float | list[float] | list[jax.Array] | list[list[float]] | jaxFloat[Array, 'cities']

controls the overdispersion factor as in the quasilikelihood approach. The shape restrictions are the same as in ns.

1.0
accept_theta bool

whether the returned loss function should accept the theta vector (suitable for optimization) or should be parameterized by the relative growths and relative offsets, as in

def loss(
    relative_growths: array of shape (variants-1,)
    relative_offsets: array of shape (cities, variants-1)
) -> float

True
average_loss bool

whether the loss should be divided by the total number of points. By default it is false, as the loss is used to calculate confidence intervals. Setting it to true can improve the convergence of the optimization procedure

False

Note

The "loglikelihood" is effectively rescaled by ns/overdispersion factor. Hence, using both ns and overdispersion should generally be avoided.

covvfit.quasimultinomial.construct_model(ys, ts, ns=1.0, overdispersion=1.0, sigma_growth=10.0, sigma_offset=1000.0)

Builds a NumPyro model suitable for sampling from the quasiposterior.

Parameters:

Name Type Description Default
ys list

list of variant proportions array for each city. The ith entry should be an array of shape (n_timepoints[i], n_variants)

required
ts list

list of timepoint arrays. The ith entry should be an array of shape (n_timepoints[i],) Note: ts should be appropriately normalized

required
ns float | list[float] | list[jax.Array] | list[list[float]] | jaxFloat[Array, 'cities']

controls the quasimultinomial sample size of each city. It can be: - a single float (sample size is constant across all cities and timepoints) - a sequence of floats, describing one sample size for each city - a list of arrays, with the ith entry having length n_timepoints[i]

1.0
overdispersion float | list[float] | list[jax.Array] | list[list[float]] | jaxFloat[Array, 'cities']

controls the overdispersion factor as in the quasilikelihood approach. The shape restrictions are the same as in ns.

1.0
sigma_growth float

controls the standard deviation of the prior on the relative growths

10.0
sigma_offset float

controls the standard deviation of the prior on the relative offsets

1000.0

Note

The "loglikelihood" is effectively rescaled by ns/overdispersion factor. Hence, using both ns and overdispersion should generally be avoided.