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

run meridian using monthly data #548

Open
marwawer1 opened this issue Mar 3, 2025 · 1 comment · May be fixed by #558
Open

run meridian using monthly data #548

marwawer1 opened this issue Mar 3, 2025 · 1 comment · May be fixed by #558
Labels
enhancement New feature or request

Comments

@marwawer1
Copy link
Collaborator

Hi,

I wanted to run Meridian using monthly data, but due to the interval days check, it requires equal intervals between observations, which is inconvenient for monthly data. Is there a way to modify this requirement for monthly data so that we can, for example, prepare data for the first day of each month? I believe this error might occur quite often,
so it might be beneficial to work on a general solution.

Please see below interval_days() method in https://github.com/google/meridian/tree/main/meridian/data/time_coordinates.py

@functools.cached_property
def interval_days(self) -> int:
"""Returns the interval between two neighboring dates in all_dates.

Raises:
  ValueError if the date index is not regularly spaced.
"""
# Calculate the difference between consecutive dates, in days.
diff = self.datetime_index.to_series().diff().dt.days.dropna()

if diff.nunique() == 0:
  # This edge case happens when there is only one date in the index.
  # This is unlikely to happen in practice, but we handle it just in case.
  warnings.warn(
      "The time coordinates only have one date. Returning an interval of 0."
  )
  return 0

Please see below the error I encountered when I tried to run Meridian using monthly data with observations on the first day of each month.

Image

Best Regards,
Marlena

@cpulavarthi cpulavarthi added the enhancement New feature or request label Mar 5, 2025
@cpulavarthi
Copy link
Collaborator

Hello Marlena,

Thank you for highlighting the issues you are facing with the interval days check. We recommend using equally spaced 30 day intervals for monthly data.

We will take your feedback into consideration and check if it is feasible to modify and implement this in Meridian. You can track the previous changes to Meridian and unreleased feature updates in our Change Log.

Feel free to reach out for any further queries or suggestions regarding Meridian!

Google Meridian Support Team

copybara-service bot pushed a commit that referenced this issue Mar 5, 2025
copybara-service bot pushed a commit that referenced this issue Mar 5, 2025
copybara-service bot pushed a commit that referenced this issue Mar 5, 2025
copybara-service bot pushed a commit that referenced this issue Mar 5, 2025
copybara-service bot pushed a commit that referenced this issue Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants