[Python] ValueError: zero-size array to reduction operation maximum which has no identity in...

Discussão em 'Python' iniciado por Stack, Junho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to fit a Structural Vector Autoregression (SVAR) model using statsmodels in Python, but I'm encountering the following error ValueError: zero-size array to reduction operation maximum which has no identity.

    There is my code:

    import pandas as pd
    import numpy as np
    from statsmodels.tsa.vector_ar.svar_model import SVAR

    df_sample = pd.DataFrame(
    {
    'Product_1': np.random.rand(240) * 10000,
    'Product_2': np.random.rand(240) * 10000,
    'Product_3': np.random.rand(240) * 10000
    },
    index=pd.date_range(start='2019-11-16', periods=240, freq='W-SAT'))

    A = np.array([
    [1, 0, 0],
    [np.nan, 1, 0],
    [np.nan, np.nan, 1]
    ], dtype='U')

    # Fit SVAR
    model = SVAR(df_sample, svar_type='A', A=A)
    res = model.fit(maxlags=4)

    Continue reading...

Compartilhe esta Página