[Python] Implementing survey weights in statsmodels OrderedModel ordinal logistic regression

Discussão em 'Python' iniciado por Stack, Março 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to run an ordinal logistic regression on survey data and implementing existing survey weights (stored in a column in the dataframe) in the model. I am using statsmodels.miscmodels.OrderedModel. As far as I can see, there are no properties for weights for this model. How can I successfully use the survey weights (one weight for each observation) given that my data has ordinal nature (cannot really use any other regression models)? Is there a workaround?

    This is my code now, without weights. It works, but output is unweighted:

    model = OrderedModel(y, X, distr='logit')
    results = model.fit(method='bfgs', disp=False)


    Tried:

    results = model.fit(method='bfgs', disp=False, weights = my_survey_weights)


    Having my_survey_weights corresponding to the relevant column in the df. Get warning that 'weight' argument has no effect on the optimizer. Played around a bit in R, but ultimately I need it to work in Python.

    Continue reading...

Compartilhe esta Página