Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

predictions(., hypothesis) arguments inconsistency bw python and R #142

Closed
apoorvalal opened this issue Dec 2, 2024 · 5 comments
Closed

Comments

@apoorvalal
Copy link

The accompanying python replication code to the JSS article does not work at the following two lines

marg.predictions(m, by="democracy", hypothesis="b2 = b1 * 2")
marg.predictions(
    m, by="democracy", hypothesis="b2 = b1 * 2", equivalence=[-0.2, 0.2]
).select("term", "estimate", "std_error", "p_value_equiv")

with NameError: name 'b2' is not defined.

A notebook demo-ing the correct python code either in the repo or the marginal effect zoo would be great.

@vincentarelbundock
Copy link
Owner

lol this is embarrassing.

Crazy week, but I'll look into it soon. Should be an easy fix.

Or maybe @artiom-matvei has time to take a look.

@vincentarelbundock
Copy link
Owner

Might be a b0 vs b1 issue. I think we decided it was necessary to make a breaking change so that Python used zero indexing.

@artiom-matvei
Copy link
Contributor

@vincentarelbundock is there a way for me to update the replication code?

@pvsundar
Copy link

pvsundar commented Dec 4, 2024

From @drsundar.bsky.social

#corrected code chunk:
#Merely change b2 to b1; and b1 to b0.

avg_predictions(m,
by = "democracy",
hypothesis = "pairwise")

predictions(m,
by = "democracy",
hypothesis = "b1 = b0 * 2")

predictions(m,
by = "democracy",
hypothesis = "b1 = b0 * 2",
equivalence = [-.2, .2])
.select("term", "estimate", "std_error", "p_value_equiv")

@vincentarelbundock
Copy link
Owner

Thanks everyone for confirming that the index of hypotheses in Python must start at b0. This is a type in the Python replication package.

I will collect a list of errors and typos found in the JSS here: vincentarelbundock/marginaleffects#1293

After a while, I'll try to update the package at JSS, but I'm not sure if they will let me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants