Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to forecast with InnovationMLR model? #40

Open
adalisan opened this issue Sep 30, 2024 · 0 comments
Open

how to forecast with InnovationMLR model? #40

adalisan opened this issue Sep 30, 2024 · 0 comments

Comments

@adalisan
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant