[Python] error using statsmodels OLS: returning nan values

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a data set like:

    Growth NHSPSTY% Index USURTOT Index GLPFTOCI Index CPTICHNG Index NAPMPMI Index RSTAXYOY Index SAARTOTL Index USASHVTK Index CONCCONF Index LEI TOTL Index SPX Index TOT_DEBT_TO_TOT_EQY BDIY Index cry index CO1 Comdty
    Date
    1998-03-31 4.1 7.5 4.7 0.121000 83.5325 52.9 2.9 -0.032258 0.404 133.80 88.9 0.455185 197.26 966 169.04 14.26
    1998-06-30 3.8 9.8 4.5 0.125556 82.2970 48.9 4.5 0.154930 0.393 138.23 88.6 0.280973 204.65 856 152.58 13.38


    I wanted to run a OLS regression but all the parameters returned all nan values. And it warned:

    /Users/jake/anaconda3/lib/python3.6/site-packages/scipy/stats/_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in greater
    return (self.a < x) & (x < self.b)
    /Users/jake/anaconda3/lib/python3.6/site-packages/scipy/stats/_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in less
    return (self.a < x) & (x < self.b)
    /Users/jake/anaconda3/lib/python3.6/site-packages/scipy/stats/_distn_infrastructure.py:1821: RuntimeWarning: invalid value encountered in less_equal
    cond2 = cond0 & (x <= self.a)


    coef std err t P>|t| [0.025 0.975]
    const nan nan nan nan nan nan
    NHSPSTY% Index nan nan nan nan nan nan
    USURTOT Index nan nan nan nan nan nan
    GLPFTOCI Index nan nan nan nan nan nan
    CPTICHNG Index nan nan nan nan nan nan


    My command:

    import statsmodels.api as sm
    model = sm.OLS(data.Growth,sm.add_constant(data.iloc[:,1:])).fit()
    model.summary()

    Continue reading...

Compartilhe esta Página