juliasilge / juliasilge.com

My blog, built with blogdown and Hugo :link:
https://juliasilge.com/
40 stars 27 forks source link

The Bechdel test and the X-Mansion with tidymodels and #TidyTuesday | Julia Silge #67

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

The Bechdel test and the X-Mansion with tidymodels and #TidyTuesday | Julia Silge

A data science blog

https://juliasilge.com/blog/uncanny-xmen/

conlelevn commented 2 years ago

Hi Julia,

There are several coefficient info in our boot_models, but after used int_pctl() function there only 5 left. What is int_pctl() function working behind the scene to return only 5 coefficients to us? what criteria does it rely on?

juliasilge commented 2 years ago

@conlelevn Do you mean that the boot_models object has coefficients for each bootstrap resample? Each of the resamples is fit with pass_bechdel ~ speech + thought + narrative + depicted so each bootstrap resample has coefficients for those terms (plus the intercept).

conlelevn commented 2 years ago

@juliasilge Thanks Julia, actually i mean to ask you: what is the used of function int_pctl()? for example, in this code lines:

set.seed(123) boots <- bootstraps(locations_joined, times = 1000, apparent = TRUE)

above we try to resample our data in 1000 boots and then fit GLM models to those boots 1000 times by this code lines:

boot_models <- boots %>% mutate( model = map( splits, ~ glm(mansion ~ speech + thought + narrative + depicted, family = "binomial", data = analysis(.) ) ), coef_info = map(model, tidy) )

try to extract the coefficient of these models out by these lines:

boot_coefs <- boot_models %>% unnest(coef_info)

and then use the final line:

int_pctl(boot_models, coef_info)

So in the boot_coefs I can see 5x1001 parameters but after using int_pctl() function I can only see 5 parameters. Does the int_pctl() function doing the average across all 5x1001 parameters and then give us a result?

juliasilge commented 2 years ago

@conlelevn Yep, if I am understanding you correctly! You can read more about this here.