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

Computing p-values for svyolr objects #1107

Closed
gjones1219 opened this issue Jun 8, 2022 · 6 comments
Closed

Computing p-values for svyolr objects #1107

gjones1219 opened this issue Jun 8, 2022 · 6 comments

Comments

@gjones1219
Copy link

gjones1219 commented Jun 8, 2022

Hello! I have written on this issue before, but am coming back to it because I do not think it was addressed before. You responded to my comment previously, and I am appreciative and apologize for not responding until now, but I do not think the functionality I was looking for was added.

I am writing to see if it would be possible for you all to assess p-values for svyolr objects. This functionality seems to be missing from the package, and would be invaluable for significance testing for ordinal logistic regression models. Attaching reproducible code for your review:

#######

library(broom)
library(survey)

data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
dclus1<-update(dclus1, mealcat=cut(meals,c(0,25,50,75,100)))

m<-svyolr(mealcat~avg.ed+mobility+stype, design=dclus1)
m

broom::tidy(m, conf.int = FALSE,
conf.level = 0.95,
exponentiate = FALSE,
p.values = TRUE)

#Usually provides an error message saying this doesn't run.

Thank you, and please let me know if I can further clarify this request!

Thanks,
gjones1219

@simonpcouch
Copy link
Collaborator

Could you please rework your reproducible example to use the reprex package? That makes it easier to see both the input and the output, formatted in such a way that I can easily re-run in a local session.

Related to #1061.

@gjones1219
Copy link
Author

Sorry about that! Here you go!

library(broom)
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#> Loading required package: survival
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
library(reprex)

data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
dclus1<-update(dclus1, mealcat=cut(meals,c(0,25,50,75,100)))

m<-svyolr(mealcat~avg.ed+mobility+stype, design=dclus1)
m
#> Call:
#> svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1)
#>
#> Coefficients:
#> avg.ed mobility stypeH stypeM
#> -2.6999217 0.0325042 -1.7574715 -0.6191463
#>
#> Intercepts:
#> (0,25]|(25,50] (25,50]|(50,75] (50,75]|(75,100]
#> -8.857919 -6.586464 -4.924938

broom::tidy(m, conf.int = FALSE,
conf.level = 0.95,
exponentiate = FALSE,
p.values = TRUE)
#> Error in UseMethod("extractAIC"): no applicable method for 'extractAIC' applied to an object of class "svyolr"
Created on 2022-06-08 by the reprex package (v2.0.1)

@simonpcouch
Copy link
Collaborator

Thanks! A slightly more minimal reprex:

library(broom)
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#> Loading required package: survival
#> 
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#> 
#>     dotchart

data(api)
dclus1 <- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
dclus1 <- update(dclus1, mealcat = cut(meals, c(0, 25, 50, 75, 100)))

m <- svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1)

tidy(m, p.values = TRUE)
#> Error in UseMethod("extractAIC"): no applicable method for 'extractAIC' applied to an object of class "svyolr"

Created on 2022-06-08 by the reprex package (v2.0.1)

The tidy.svyolr() tidier is a light wrapper around tidy.polr(). However, the implementation for p-value calculation in tidy.polr() is both computationally intensive and specific to that model, so the p.values argument to tidy.svyolr() is now ignored and will raise a warning when passed.

I appreciate you noting this!

@gjones1219
Copy link
Author

Hi Simon,

Thanks for responding however I am not sure I understand your answer. Also, I have the latest version of broom (0.8.0, I believe; please let me know if there might be a newer one) but do not see the tidy.svyolr() or tidy.poly() functions. Can you please advise here? Thanks!

Grant

@simonpcouch
Copy link
Collaborator

Sure thing—tidy.svyolr and tidy.poly are S3 methods. You can read about those methods with ?tidy.svyolr or ?tidy.poly, and learn more about them here. :)

@github-actions
Copy link

This issue 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 Jun 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants