[Python] Why would R-Squared decrease when I add an exogenous variable in OLS using python...

Discussão em 'Python' iniciado por Stack, Janeiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    If I understand the OLS model correctly, this should never be the case?

    trades['const']=1
    Y = trades['ret']+trades['comms']
    #X = trades[['potential', 'pVal', 'startVal', 'const']]
    X = trades[['potential', 'pVal', 'startVal']]

    from statsmodels.regression.linear_model import OLS
    ols=OLS(Y, X)
    res=ols.fit()
    res.summary()


    If I turn the const on, I get a rsquared of 0.22 and with it off, I get 0.43. How is that even possible?

    Continue reading...

Compartilhe esta Página