Skip to content

how to forecast with InnovationMLR model? #40

@adalisan

Description

@adalisan

I was successfully able to fit InnovationMLR models to SARS-COV2 seq. count data and get growth advantage models. How would I be able to run forecasting with such a model? There is this function that works for MultinomialLogisticRegression models,

def forecast_frequencies(post_samples, mlr, forecast_L):
    """Use posterior beta to forecast posterior frequencies.

        Args:
            samples (Dict[str,Array]): samples attribute of posterior object PosteriorHandler from evofr
            mlr (ModelSpec): model object from evofr
            forecast_L (int): forecasting length in days

        Returns:
            Array: freq. estimates for posterior
        """

    # Making feature matrix for forecasting
    last_T = post_samples["freq"].shape[1]

    X = mlr.make_ols_feature(start=last_T, stop=last_T + forecast_L)
    # Posterior beta
    beta = jnp.array(post_samples["beta"])

    # Matrix multiplication by sample
    dot_by_sample = vmap(jnp.dot, in_axes=(None, 0), out_axes=0)
    logits = dot_by_sample(X, beta)  # Logit frequencies by variant
    return softmax(logits, axis=-1)

we have the predictor values in the "predictors" array
predictors = np.empty((N_variants, n_features))
#load predictor values into numpy array 
how can I adapt the forecast_frequencies functions to forecast with the model forecast_L days in to the future?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions