Questions tagged [broom]

broom is an R package for converting statistical analysis objects into "tidy" data frames

Thebroom package provides functions for converting statistical analysis objects into "tidy" tibbles in the R programming language.

The three main verbs of broom are:

  • tidy() summarizes information about model components;
  • glance() reports information about the entire model;
  • augment() adds informations about observations to a dataset.

For more information:

339 questions
3
votes
1 answer

R - dplyr bootstrap issue

I have an issue understanding how to use the dplyr bootstrap function properly. What I want is to generate a bootstrap distribution from two randomly assigned groups and compute the difference in means, like this for example : library(dplyr)…
giac
  • 4,261
  • 5
  • 30
  • 59
3
votes
1 answer

R: How to apply a function that outputs a dataframe for multiple columns (using dplyr)?

I want to find correlations, p-values and 95% CI between one specific column and all other columns in a dataframe. The 'broom' package provides an example how to do that between two columns using cor.test with dplyr and pipes. For mtcars and, say,…
Irakli
  • 959
  • 1
  • 11
  • 18
3
votes
2 answers

How to calculate p-value from a linear mixed effect model created by lme4::lmer() using broom::tidy()?

I have a built a mixed effect model using the lmer() function from the lme4 package. The lme4 package does not output the p-value of the coefficients for some good philosophical reason. However, I still need p-values to report in my publication. I…
gruangly
  • 942
  • 8
  • 13
3
votes
1 answer

Predicted values from a series of linear models

Hi there: I have a series of linear models in a data frame constructed using tidyr and dplyr. It looks like below. How would I go about generating predicted values from each model with a fixed set of newdata? In reality I have 10 dependent…
spindoctor
  • 1,719
  • 1
  • 18
  • 42
3
votes
1 answer

broom::tidy() with do() in a dplyr workflow fails with a summaryDefault object

I want to do a numerical summary (summary.default() in the base package) on a variable in a data.frame and use tidy() in the broom package, but this somehow fails. In this example, I create a data.frame: df <- data.frame(group = c(rep('M', 6), 'F',…
2
votes
1 answer

Why is the confidence interval different when using tidy() on output of aggte() than what aggte() itself displays?

I am working with the did package performing an estimation using the conditional parallel trends assumption with only one treated group (and 7 control groups that are never treated), so only one treatment adoption time. I use the aggte() function…
tiny
  • 129
  • 6
2
votes
1 answer

How do I run a mixed linear regression model on several outcomes variables and get presentable results?

I finally gave up and admitted I need help. I have this data set with 3 different groups, measured at 2 time points and 49 outcome variables. I would like to do a mixed linear regression analysis on each outcome variable for within group change…
nlevak
  • 23
  • 4
2
votes
1 answer

ggcoef_model error when two random intercepts

When trying to graph the conditional fixed effects of a glmmTMB model with two random intercepts in GGally I get the error: There was an error calling "tidy_fun()". Most likely, this is because the function supplied in "tidy_fun=" was misspelled,…
Charlie_J
  • 89
  • 6
2
votes
1 answer

r filter and aggregate results from lapply model summary

I am trying to filter and aggregate results from multiple regression models executed on a subset of dataset using dlply. This is how I ran my models: library(plyr) data("mtcars") models = dlply(mtcars, .(cyl), function(df) lm(mpg ~…
2
votes
1 answer

Looping `lm` objects using `purrr::map` into `broom::tidy`

I have a several lm objects that I would like to loop into broom::tidy using purrr::map. Is this possible to do? library(broom) library(purrr) model1 <- lm(cyl ~ hp, data = mtcars) model2 <- lm(mpg ~ cyl, data = mtcars) map(c(model1, model2),…
John-Henry
  • 1,556
  • 8
  • 20
2
votes
1 answer

Mapping broom::tidy to nested list of {fixest} models and keep name of list element

I want to apply broom::tidy() to models nested in a fixest_multi object and extract the names of each list level as data frame columns. Here's an example of what I mean. library(fixest) library(tidyverse) library(broom) multiple_est <-…
Felix
  • 1,611
  • 13
  • 22
2
votes
1 answer

"Multi-step" regression with broom and dplyr in R

I am looking for a way to perform "multi-step" regression with broom and dplyr in R. I use "multi-step" as a placeholder for regression analyses in which you integrate in the final regression model elements of previous regression models, such as the…
timm
  • 257
  • 1
  • 10
2
votes
2 answers

alternative to broom::tidy?

In my analysis code I've been using broom::tidy to extract a regression slope per group in a data frame: E1.first_trial_df <- data.frame( search_type = factor(rep(1:3, each = 10)), set_size = rep(1:10,3), RT = runif(300, min = 0, max…
TanZor
  • 227
  • 1
  • 6
2
votes
2 answers

Extract slope and r squared from grouped linear models using broom

I have a dataframe that I want to run linear models on by group, then use the broom package to extract the slope and r squared for each model. So far I am trying this: library(tidyverse) library(broom) #read in the dataset data(mtcars) #add a…
Stefano Potter
  • 3,467
  • 10
  • 45
  • 82
2
votes
1 answer

Problems after broom update?

I had this piece of code to run multiple linear models at once separated per levels of a factor. First, I subset the data with filter and group_by and then built the model with do() and exibit the output with tidy() dados <-…