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

glance method not working for svyglm class object #572

Closed
IndrajeetPatil opened this issue Jan 6, 2019 · 5 comments
Closed

glance method not working for svyglm class object #572

IndrajeetPatil opened this issue Jan 6, 2019 · 5 comments

Comments

@IndrajeetPatil
Copy link
Contributor

# data
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
set.seed(123)
data(api)
dstrat <-
  svydesign(
    id =  ~ 1,
    strata =  ~ stype,
    weights =  ~ pw,
    data = apistrat,
    fpc =  ~ fpc
  )

# model
mod <- survey::svyglm(
  formula = sch.wide ~ ell + meals + mobility,
  design = dstrat,
  family = quasibinomial()
)

# tidier
broom::tidy(mod)
#> # A tibble: 4 x 5
#>   term        estimate std.error statistic p.value
#>   <chr>          <dbl>     <dbl>     <dbl>   <dbl>
#> 1 (Intercept)  0.836     0.456       1.83   0.0681
#> 2 ell         -0.00249   0.0133     -0.188  0.851 
#> 3 meals       -0.00315   0.00920    -0.343  0.732 
#> 4 mobility     0.0609    0.0319      1.91   0.0580

# glance
broom::glance(mod)
#> Warning in logLik.svyglm(x): svyglm not fitted by maximum likelihood.
#> Error in `$<-.data.frame`(`*tmp*`, "AIC", value = c(eff.p = 2.86358934805296, : replacement has 3 rows, data has 1

Created on 2019-01-06 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> - Session info ----------------------------------------------------------
#>  setting  value                                             
#>  version  R Under development (unstable) (2018-11-30 r75724)
#>  os       Windows 10 x64                                    
#>  system   x86_64, mingw32                                   
#>  ui       RTerm                                             
#>  language (EN)                                              
#>  collate  English_United States.1252                        
#>  ctype    English_United States.1252                        
#>  tz       Asia/Calcutta                                     
#>  date     2019-01-06                                        
#> 
#> - Packages --------------------------------------------------------------
#>  package     * version     date       lib
#>  assertthat    0.2.0       2017-04-11 [1]
#>  backports     1.1.3       2018-12-14 [1]
#>  broom         0.5.1.9000  2018-12-24 [1]
#>  callr         3.1.1       2018-12-21 [1]
#>  cli           1.0.1.9000  2018-10-30 [1]
#>  crayon        1.3.4       2017-09-16 [1]
#>  desc          1.2.0       2018-10-30 [1]
#>  devtools      2.0.1       2018-10-26 [1]
#>  digest        0.6.18      2018-10-10 [1]
#>  dplyr         0.8.0       2019-01-06 [1]
#>  evaluate      0.12        2018-10-09 [1]
#>  fansi         0.4.0       2018-11-05 [1]
#>  fs            1.2.6       2018-08-23 [1]
#>  generics      0.0.2       2018-11-29 [1]
#>  glue          1.3.0       2018-07-17 [1]
#>  highr         0.7         2018-06-09 [1]
#>  htmltools     0.3.6       2017-04-28 [1]
#>  knitr         1.21        2018-12-10 [1]
#>  lattice       0.20-38     2018-11-04 [2]
#>  magrittr      1.5         2014-11-22 [1]
#>  Matrix      * 1.2-15      2018-11-01 [1]
#>  memoise       1.1.0       2017-04-21 [1]
#>  pillar        1.3.1       2018-12-15 [1]
#>  pkgbuild      1.0.2       2018-10-16 [1]
#>  pkgconfig     2.0.2       2018-08-16 [1]
#>  pkgload       1.0.2       2018-10-29 [1]
#>  prettyunits   1.0.2       2015-07-13 [1]
#>  processx      3.2.1       2018-12-05 [1]
#>  ps            1.3.0       2018-12-21 [1]
#>  purrr         0.2.99.9000 2019-01-04 [1]
#>  R6            2.3.0       2018-10-04 [1]
#>  Rcpp          1.0.0       2018-11-07 [1]
#>  remotes       2.0.2       2018-10-30 [1]
#>  rlang         0.3.0.9002  2019-01-04 [1]
#>  rmarkdown     1.11        2018-12-08 [1]
#>  rprojroot     1.3-2       2018-01-03 [1]
#>  sessioninfo   1.1.1       2018-11-05 [1]
#>  stringi       1.2.4       2018-07-20 [1]
#>  stringr       1.3.1       2018-05-10 [1]
#>  survey      * 3.35        2018-12-17 [1]
#>  survival    * 2.43-3      2018-11-26 [2]
#>  testthat      2.0.1       2018-10-13 [1]
#>  tibble        2.0.0       2019-01-04 [1]
#>  tidyr         0.8.2       2018-10-28 [1]
#>  tidyselect    0.2.5       2018-10-11 [1]
#>  usethis       1.4.0.9000  2018-12-12 [1]
#>  utf8          1.1.4       2018-05-24 [1]
#>  withr         2.1.2       2018-03-15 [1]
#>  xfun          0.4         2018-10-23 [1]
#>  yaml          2.2.0       2018-07-25 [1]
#>  source                           
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  Github (tidymodels/broom@a1ac666)
#>  CRAN (R 3.6.0)                   
#>  Github (r-lib/cli@56538e3)       
#>  CRAN (R 3.5.1)                   
#>  Github (r-lib/desc@7c12d36)      
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  Github (tidyverse/dplyr@59d4600) 
#>  CRAN (R 3.5.1)                   
#>  Github (brodieG/fansi@ab11e9c)   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.6.0)                   
#>  Github (tidyverse/purrr@3b4a013) 
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.6.0)                   
#>  Github (r-lib/rlang@67ff440)     
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.2)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  Github (tidyverse/tibble@d06dd5c)
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#>  Github (r-lib/usethis@923dd75)   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.5.1)                   
#>  CRAN (R 3.6.0)                   
#>  CRAN (R 3.5.1)                   
#> 
#> [1] C:/Users/inp099/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-devel/library
@briatte
Copy link
Contributor

briatte commented Feb 26, 2019

Related question -- if svyglm is supported, why isn't it listed in the available methods? svyolr is, but not svyglm.

@alexpghayes
Copy link
Collaborator

alexpghayes commented Feb 27, 2019

Either the pkgdown hasn't been updated or the logic to find existing methods doesn't catch the svyolr tidiers because of the ordinal amalgam. Those all really need to get separated out at some point, which should fix this.

Edit: svyglm isn't supported! There was a PR that added a bunch of tidiers for ordinal models all at once, but it didn't include a tidier for svyglm(). It would be nice to add that!

@briatte
Copy link
Contributor

briatte commented Feb 28, 2019

@alexpghayes I'll give it a try very soon.

@briatte
Copy link
Contributor

briatte commented Feb 28, 2019

Done, see PR #611, which contains a description of the solution and the further problems that it raises.

@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 Mar 10, 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

No branches or pull requests

3 participants