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

BUG: data as observed in RV #7649

Open
wd60622 opened this issue Jan 16, 2025 · 0 comments · May be fixed by #7656
Open

BUG: data as observed in RV #7649

wd60622 opened this issue Jan 16, 2025 · 0 comments · May be fixed by #7656
Labels

Comments

@wd60622
Copy link
Contributor

wd60622 commented Jan 16, 2025

Describe the issue:

Example:

pymc-labs/pymc-marketing#1383 (comment)

Reproduceable code example:

import numpy as np
import pymc as pm

seed = sum(map(ord, "Scaling the likelihood depended variables doesn't work in PyMC"))
rng = np.random.default_rng(seed)

true_mu = 100
true_sigma = 30

n_obs = 10
coords = {
    "date": np.arange(n_obs),
}

dist = pm.Normal.dist(mu=true_mu, sigma=true_sigma, shape=n_obs)
data = pm.draw(dist, random_seed=rng)

scaling = data.max()

with pm.Model(coords=coords) as model:
    mu = pm.Normal("mu")
    sigma = pm.HalfNormal("sigma")

    target = pm.Data("target", data, dims="date")
    scaled_target = target / scaling

    pm.Normal("observed", mu=mu, sigma=sigma, observed=scaled_target)

Error message

            if not is_valid_observed(observed):
>               raise TypeError(
                    "Variables that depend on other nodes cannot be used for observed data."
                    f"The data variable was: {observed}"
                )
E               TypeError: Variables that depend on other nodes cannot be used for observed data.The data variable was: True_div.0

PyMC version information:

5.20.0

Context for the issue:

Would like to define my scaling within the model definition

@wd60622 wd60622 added the bug label Jan 16, 2025
@wd60622 wd60622 linked a pull request Jan 24, 2025 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant