juliasilge / tidytext

Text mining using tidy tools :sparkles::page_facing_up::sparkles:

Home Page:https://juliasilge.github.io/tidytext/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support conf.int argument in `tidy()` function

jooyoungseo opened this issue · comments

Currently, tidytext::tidy() does not support conf.int option for estimateEffect object. It would be great if it could be added.

Reprex

library(stm)
#> stm v1.3.6 successfully loaded. See ?stm for help. 
#>  Papers, resources, and other materials at structuraltopicmodel.com
library(tidytext)

prep <- estimateEffect(c(1) ~ treatment, gadarianFit, gadarian)
tidy(prep, conf.int = TRUE)
#> # A tibble: 2 x 6
#>   topic term        estimate std.error statistic  p.value
#>   <int> <chr>          <dbl>     <dbl>     <dbl>    <dbl>
#> 1     1 (Intercept)    0.437    0.0206     21.2  3.75e-64
#> 2     1 treatment     -0.150    0.0309     -4.86 1.77e- 6

Created on 2021-05-13 by the reprex package (v2.0.0)

I also was wondering if this could be integrated into broom::tidy() and tidytext::tidy() use that as a wrapper function. Just thought.

The reason that tidytext doesn't support a conf.int option for this model is that there isn't a confint.estimateEffect method from the stm package. You can see how the broom:::broom_confint_terms() function for lm() type models works here, and notice that stm doesn't have the needed confint method for estimateEffect. You could ask the maintainer Brandon what he thinks about this and if it makes sense to support that functionality.

And broom is always looking to support fewer models, not more (it is so unwieldy as is), so it makes more sense to keep the text-specific model tidiers here in tidytext.

Let me know if you get any further info on a confint method from the stm package! 🙌

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.