benmiroglio / pymatch

MIT License
272 stars 128 forks source link

Get the Fit of the model itself #16

Open rm17tink opened 5 years ago

rm17tink commented 5 years ago

Does anyone have a clean way to extract the summary file of the models behavior from this? It doesnt seem like there is a call from the .fit() glm_binom = sm.GLM(data.endog, data.exog, family=sm.families.Binomial()) res = glm_binom.fit() print(res.summary())

mc51 commented 5 years ago

The models get appended to the models list. check this out:

m = Matcher(test, control, yvar="population", exclude=['label'])
m.fit_scores(balance=True, nmodels=10)

Now you can access all 10 models. To return the first: m.models[0]

rm17tink commented 5 years ago

Thanks. This didnt do anything. Would it be possible to get a print out of a GLM as well? What would be the easiest way to replicate what takes place in the PSM? I know its taboo, but just trying to take a look inside.

mc51 commented 5 years ago

I don't think I understand you. Can you please be more specific? With the method I mentioned you can in fact look at all information regarding the GLM. That includes a print out of the model formula, parameters etc.

The code for the GLM calculation in the source is here. It's just a basic way to calculate a Logistic Regression via GLM.

rm17tink commented 5 years ago

It only gives me this output <statsmodels.genmod.generalized_linear_model.GLMResultsWrapper at 0x1b1ac859198> even if I print(models[0]) also anything past models[0] e.g models[1] gives an error list index out of range

menonshyam15 commented 2 years ago

@rm17tink m.models[0].summary() will give you the summary file of that specific model