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
1
vote
2 answers

How to efficiently run many logistic regressions in R and skip over equations that throw errors?

As a continuation from this question, I want to run many logistic regression equations at once and then note if a group was significantly different from a reference group. This solution works, but it only works when I'm not missing values. Being…
J.Sabree
  • 2,280
  • 19
  • 48
1
vote
3 answers

Tidy multiple univariate regressions

db = tibble(a = rnorm(100), b = rnorm(100), c = rnorm(100)) If I want a tidy multivariate linear regression, I just can go lm(data = db, 0 + a ~ b + c) %>% tidy() But if I want multiple univariate regressions I would go lm(data = db, a ~ 0 + b)…
GiulioGCantone
  • 195
  • 1
  • 10
1
vote
1 answer

Grouped regression with dplyr using different formulas

I try to transfer the problem from this post to a setting where you use different formulas in the lm() function in R. Here a basic setup to reproduce the problem: library(dplyr) library(broom) library(purrr) library(tidyr) # Generate…
timm
  • 257
  • 1
  • 10
1
vote
1 answer

Using the broom::tidy to add confidence intervals to linear models in nested data frame

I've been trying follow the approach set out by Hadley Wickham for running multiple models in a nested data frame as per https://r4ds.had.co.nz/many-models.html I've managed to write this code below to create the multiple linear models: #create…
RobA
  • 13
  • 2
1
vote
0 answers

How are `grouped_` variants of generics in **broomExtra** defined?

The broomExtra package allows for easy augmentation of many different broom like packages in one place. It also offers the grouped_ variants of the broom functions (tidy, augment, glance). However, is this a shortcut to use purrr::map() and then the…
phargart
  • 655
  • 3
  • 14
1
vote
1 answer

Equation-by-equation instrumental variable regression (control function) in R

I want to do a equation-by-equation instrumental variable (IV) regression with a control function in R (using tidyverse and broom). I want to implement this based on a grouped data frame with a dependent variable, y, an endogenous variable, x, an…
timm
  • 257
  • 1
  • 10
1
vote
1 answer

applying a glm to the same outcome variable using several different predictors in purrr, broom, and dplyr1.0.0

In this post I was shown how to run several glms on several outcomes using the same predictor using the functionality in purrr and broom packages. Now I would like to do the reverse, applying one glm each to several models with different predictors…
llewmills
  • 2,959
  • 3
  • 31
  • 58
1
vote
1 answer

aov throws "could not find function 'Error'" when used in the context of group_by

I'm trying to run a repeated measures ANCOVA. The following code works fine: tidy(aov(FA ~ sex * study + Error(PartID), data = DTI.TRACTlong)) Where FA is a continuous measure, sex and study are factors where study indicates (time 1 or time 2) and…
1
vote
1 answer

iterating over variables and replacing one on each iteration

Say I have this df: df <- structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8), q1 = c(1, 1, 4, 5, 3, 3, 3, 2), q2 = c(5, 4, 4, 1, 1, 2, 3, 3), q3 = c(3, 3, 2, 4, 3, 3, 2, 5), q4 = c(6, 5, 3, 3, 2, 1, 3, 4), q5 = c(2, 1, 3, 4, 5, 4, 3, 2), v1 = c(0, 0,…
C.Robin
  • 1,085
  • 1
  • 10
  • 23
1
vote
1 answer

Using a custom `glance` method in huxtable::huxreg()

I am looking for a way to report the number of groups alongside the number of observations using huxtable::huxreg to create a table of results of a multilevel model predicted with lmer(). I can write a custom glance method that overwrites the…
mikebader
  • 1,075
  • 3
  • 12
1
vote
1 answer

Error: No tidy method for objects of class function :: broom.mixed

I am trying to perform a linear regression fit using tidymodels,parsnip but encounters the following error: Error: No tidy method for objects of class function routine: library(tidymodels) library(parsnip) library(broom.mixed) linear_reg() %>% …
Ranji Raj
  • 778
  • 4
  • 18
1
vote
1 answer

Make predictions after merging estimated models in a dataframe for all observations using broom and dplyr

I am working in a modeling problem where I have to estimate multiple models per group using specific variables. After having all models per groups I need to compute the estimated values (fitted values) and standard errors (se) for all of them. I…
Duck
  • 39,058
  • 13
  • 42
  • 84
1
vote
1 answer

How to create tidy correlations using nested dataframes?

This question has been partially answered previously (e.g., here), but – as far as I can tell – there is no full answer using a reproducible example. I would like to select variables by name from a nested data frame, calculate pairwise correlations,…
nicholas
  • 903
  • 2
  • 12
1
vote
2 answers

Remove auto-generated prefixes from `pivot_longer` output

How do I remove the (Intercept)_ and (carat)_ prefixes in my table? That way, I could shrink my table's width a little bit and remove name redundancy. Using names_prefix = "" in pivot_longer() or pivot_wider() or both, similar to pivot_longer issue…
hnguyen
  • 772
  • 6
  • 17
1
vote
1 answer

Data frame/output not displaying after piping through custom function

I am wondering why only in some instances R produces the output of the data frame/tibble on the console after piping it into a function. Below is a reproducible example. I first define a custom function called make_stars() because I would like to…