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

tieders for ordinal models #332

Merged
merged 3 commits into from
Jun 8, 2018
Merged

Conversation

larmarange
Copy link
Contributor

cf. #292 and #156

Some examples:

> library(ordinal)
> clm_mod <- clm(rating ~ temp * contact, data = wine)
>   tidy(clm_mod)
                 term   estimate std.error  statistic      p.value coefficient_type
1                 1|2 -1.4112620 0.5453532 -2.5877943 9.659266e-03            alpha
2                 2|3  1.1435537 0.5096555  2.2437776 2.484671e-02            alpha
3                 3|4  3.3770825 0.6381617  5.2918913 1.210578e-07            alpha
4                 4|5  4.9419823 0.7509113  6.5813133 4.663108e-11            alpha
5            tempwarm  2.3211843 0.7009479  3.3114931 9.279953e-04             beta
6          contactyes  1.3474604 0.6603557  2.0405072 4.129984e-02             beta
7 tempwarm:contactyes  0.3595489 0.9238188  0.3891985 6.971293e-01             beta
>   tidy(clm_mod, conf.int = TRUE)
                 term   estimate std.error  statistic      p.value    conf.low conf.high coefficient_type
1                 1|2 -1.4112620 0.5453532 -2.5877943 9.659266e-03          NA        NA            alpha
2                 2|3  1.1435537 0.5096555  2.2437776 2.484671e-02          NA        NA            alpha
3                 3|4  3.3770825 0.6381617  5.2918913 1.210578e-07          NA        NA            alpha
4                 4|5  4.9419823 0.7509113  6.5813133 4.663108e-11          NA        NA            alpha
5          contactyes  1.3474604 0.6603557  2.0405072 4.129984e-02  0.08378091  2.694828             beta
6            tempwarm  2.3211843 0.7009479  3.3114931 9.279953e-04  0.99435182  3.761793             beta
7 tempwarm:contactyes  0.3595489 0.9238188  0.3891985 6.971293e-01 -1.45985126  2.180286             beta
>   tidy(clm_mod, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE)
                 term    estimate std.error  statistic      p.value    conf.low   conf.high coefficient_type
1                 1|2   0.2438354 0.5453532 -2.5877943 9.659266e-03  0.08373195   0.7100717            alpha
2                 2|3   3.1378996 0.5096555  2.2437776 2.484671e-02  1.15563177   8.5203732            alpha
3                 3|4  29.2852064 0.6381617  5.2918913 1.210578e-07  8.38386057 102.2945581            alpha
4                 4|5 140.0475848 0.7509113  6.5813133 4.663108e-11 32.14391711 610.1722432            alpha
5          contactyes   3.8476417 0.6603557  2.0405072 4.129984e-02  1.05462698  14.0375196             beta
6            tempwarm  10.1877321 0.7009479  3.3114931 9.279953e-04  2.57887058  40.2462558             beta
7 tempwarm:contactyes   1.4326830 0.9238188  0.3891985 6.971293e-01  0.23431175   8.7600407             beta
>   glance(clm_mod)
  edf   logLik      AIC      BIC df.residual
1   7 -86.4162 186.8324 202.7691          65
>   head(augment(clm_mod))
  rating temp contact    .fitted    .se.fit
1      2 cold      no 0.56229641 0.08849613
2      3 cold      no 0.20864908 0.07883377
3      3 cold     yes 0.43467309 0.08370346
4      4 cold     yes 0.08938852 0.04360852
5      4 warm      no 0.19028226 0.07112858
6      4 warm      no 0.19028226 0.07112858
> 
>   clm_mod2 <- clm(rating ~ temp, nominal = ~ contact, data = wine)
>   tidy(clm_mod2)
             term  estimate std.error statistic      p.value coefficient_type
1 1|2.(Intercept) -1.323043 0.5622762 -2.353013 1.862196e-02            alpha
2 2|3.(Intercept)  1.246444 0.4748240  2.625064 8.663257e-03            alpha
3 3|4.(Intercept)  3.550044 0.6560234  5.411459 6.251335e-08            alpha
4 4|5.(Intercept)  4.660247 0.8604027  5.416356 6.082600e-08            alpha
5  1|2.contactyes -1.615059 1.1618005 -1.390135 1.644880e-01            alpha
6  2|3.contactyes -1.511567 0.5906414 -2.559196 1.049144e-02            alpha
7  3|4.contactyes -1.674756 0.6488373 -2.581164 9.846770e-03            alpha
8  4|5.contactyes -1.050623 0.8965109 -1.171902 2.412364e-01            alpha
9        tempwarm  2.519045 0.5350470  4.708081 2.500591e-06             beta
> 
>   clmm_mod <- clmm(rating ~ temp + contact + (1 | judge), data = wine)
>   tidy(clmm_mod)
        term  estimate std.error statistic      p.value coefficient_type
1        1|2 -1.623667 0.6824432 -2.379197 1.735040e-02            alpha
2        2|3  1.513365 0.6037564  2.506582 1.219047e-02            alpha
3        3|4  4.228527 0.8089694  5.227054 1.722324e-07            alpha
4        4|5  6.088773 0.9724566  6.261228 3.819575e-10            alpha
5   tempwarm  3.062997 0.5953779  5.144626 2.680538e-07             beta
6 contactyes  1.834885 0.5125301  3.580053 3.435243e-04             beta
>   glance(clmm_mod)
  edf    logLik      AIC      BIC
1   7 -81.56541 177.1308 193.0675

@alexpghayes
Copy link
Collaborator

Nice! Looks like the tests are failing for some reason? I'd add survey to Suggests too.

I'm totally blown away by how many PRs you've been submitting -- much appreciated!

@larmarange
Copy link
Contributor Author

A data command was missing in the test !!

@alexpghayes alexpghayes merged commit 6f8bb48 into tidymodels:master Jun 8, 2018
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants