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

Predicted probability labeling #13

Closed
shannonpileggi opened this issue Jun 30, 2021 · 3 comments
Closed

Predicted probability labeling #13

shannonpileggi opened this issue Jun 30, 2021 · 3 comments

Comments

@shannonpileggi
Copy link

Hi John! Thanks for this awesome package! I was reviewing Predicting Choice Probabilities from Estimated Models and I noticed that the predicted probabilities don't carry forward the brand assignment:

probs_mnl_pref
#>   obsID  prob_mean   prob_low  prob_high
#> 1    13 0.43684871 0.41564967 0.45746384
#> 2    13 0.03313009 0.02630457 0.04172679
#> 3    13 0.19155738 0.17621753 0.20760195
#> 4    13 0.33846382 0.31891924 0.35883234
#> 5    42 0.60763975 0.57328271 0.64024329
#> 6    42 0.02602079 0.01832816 0.03662558
#> 7    42 0.17803594 0.16244937 0.19462645
#> 8    42 0.18830353 0.16858802 0.20970439

is it safe to assume that those are in the same order of the input new data here?

alts
#>     obsID price feat   brand
#> 49     13   8.1    0  dannon
#> 50     13   5.0    0  hiland
#> 51     13   8.6    0  weight
#> 52     13  10.8    0 yoplait
#> 165    42   6.3    0  dannon
#> 166    42   6.1    1  hiland
#> 167    42   7.9    0  weight
#> 168    42  11.5    0 yoplait

And can the predictProbs function be modified to include brand as a column in the predicted probabilities data frame? This could help protect users against misspecification.

Thank you again for all of your work on this!

@jhelvy
Copy link
Owner

jhelvy commented Jun 30, 2021

Hmm, good points. The row order is preserved, so yes the predicted probabilities align with the original alts data frame. But you're right that a user could very easily mix this up. I think all I need is to add an altIDName argument that identifies the alternative, similar to how the obsIDName identifies the choice observation. I'll make this update.

In the specific yogurt example, there's actually an alt variable that IDs the alternative, though you could just as well use brand.

@jhelvy jhelvy closed this as completed in 3023d9f Jun 30, 2021
@jhelvy
Copy link
Owner

jhelvy commented Jun 30, 2021

Okay, I bumped the version to 0.2.1. If you install from Github you should now be able to include a altIDName argument to both prediction functions.

@shannonpileggi
Copy link
Author

Wow, thanks for addressing this so quickly!

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

2 participants