vincentarelbundock / pymarginaleffects

GNU General Public License v3.0
47 stars 8 forks source link

Joint hypotheses #94

Closed LamAdr closed 4 months ago

LamAdr commented 4 months ago

Here is my go at joint hypotheses testing. It seems pymarginaleffects does not support making hypotheses about comparisons/slopes objects yet, and I didn't change that. I made changes to two other files :

  1. classes.py
    • added the capability to change the mapping used to change column names at print time
    • added a dataframe header print_head to match R's output
  2. model_statsmodel.py
    • get_variables_names() now keeps the variables in the order they appear in the formula. That's useful if users want to specify which variable they're hypothesizing on based on their indices.
    • added the get_df function

One potentially problematic assumption is that the presence of the intercept is verified with len(theta_hat) == len(var_names)+1.

Thanks

vincentarelbundock commented 4 months ago

Thanks! Are the tests hard-coded numbers verified against R?

FYI, I'm not planning to allow hypotheses() to process slopes or comparisons or predictions objects. I regret this design choice in R. Users should just use the hypothesis argument instead of a separate function call.

LamAdr commented 4 months ago

Are the tests hard-coded numbers verified against R?

You mean as in e.g.

hypo_py = hypotheses(mod, joint=[0, 1, 2], hypothesis=[1, 2, 3])

? If so, yes, I generated a csv using the corresponding R call.

I'm not planning to allow hypotheses() to process slopes or comparisons or predictions objects.

In that case maybe we should rename the input obj to model or mod?

vincentarelbundock commented 4 months ago

Let's do exact parallelism in argument names between R and Python, even if it feels a bit weird.

Let me know when I can merge. Looks great!

LamAdr commented 4 months ago

alright, I think you can merge.

vincentarelbundock commented 4 months ago

great thanks!