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

Tidyverse's tidy() function not working in R

I have a simple problem in that tidy() function in R is not working. I have tidyverse installed and have loaded it with library(tidyverse). However I get the following error message: Error in tidy(fit1b) : could not find function "tidy" I also get…
canthandlehtml
  • 83
  • 2
  • 3
  • 9
3
votes
1 answer

Using purrr map for several linear regressions for each predictor in df

I'm trying to run many individual linear regressions with one Y variable and many x variables. My data has 300+ x variables. I've been trying to do this with purrr and broom but cannot figure out how to get the output how I'd like. Example: iris <-…
Lachlan
  • 175
  • 5
3
votes
0 answers

Why does broom::tidy occasionally return a wrong type of 'estimate' with speedglm?

It is documented that broom::tidy can tidy a speedglm object: https://broom.tidyverse.org/reference/tidy.speedglm.html. In the following examples, broom::tidy a speedglm object returns some columns as 'fct' rather than 'dbl'. I guess it happens when…
Zhiqiang Wang
  • 6,206
  • 2
  • 13
  • 27
3
votes
1 answer

Tidyverse commands are becoming deprecated: T test inside a summarise , then report all results

I use tidyverse (and its environment) almost every day and from time to time I have to come back to previous/old analyses. Unfortunately, it's not easy to keep up the track of the changes that have been made to the package. This script is pretty…
Luis
  • 1,388
  • 10
  • 30
3
votes
1 answer

Working with tidyverse, ggplot, and broom to add confidence interval to a proportion test (prop.test) in R

Let's say I'm working with proportions, I have two main variables (sex and pain_level). It's not difficult to plot them: With tidyverse and broom (and thanks for this link here: Calling prop.test function in R with dplyr) I can compare if the…
Luis
  • 1,388
  • 10
  • 30
3
votes
1 answer

Fitting models to grouped data with if else conditionals

To ease reproducibility, I am using the goats data set from the ResourceSelection package which has spatial data for used (STATUS == 1) and 'available' (STATUS == 0) GPS locations of mountain goats. ID is for individual (n = 10) and ELEVATION, ... ,…
B. Davis
  • 3,391
  • 5
  • 42
  • 78
3
votes
1 answer

How to iterate through independent variables, performing multiple linear regressions using the tidyverse framework?

My data: library(tidyverse) library(lme4) myData <- structure(list(Subjects = c(4L, 3L, 5L, 1L, 9L, 6L, 10L, 2L, 8L, 7L), Gene1 = c(0.318630087617032, -0.58179068471591, 0.714532710891568, -0.825259425862769, -0.359862131395465,…
3
votes
1 answer

how to work with prais.winsten results in stargazer and broom (r)

The package "prais" contains the function prais.winsten to run a regression models with Prais Winsten estimator. However, neither stargazer nor broom packages seem to work with the results from the prais.winsten function. After fitting a model of…
jlp
  • 165
  • 1
  • 3
  • 12
3
votes
3 answers

Passing list of data frames into lm() and viewing the results

I've got three data frames, dfLON, dfMOS, and dfATA. Each features the same variables: y is a continuous variable, and a, b, and c are binary categorical, and there is also some NA. I'd like to build separate linear regression models, one for each…
LLL
  • 723
  • 1
  • 9
  • 27
3
votes
1 answer

Using broom::glance() in conjunction with glmmTMB

I've run a set of 23 models using glmmTMB. (I've set up my models as a list, example code seen below) cand.models<-list() cand.models[[1]]<-glmmTMB(count~depth + slope + SST + (1|individual), family=list(family="truncated_nbinom1", link="log"),…
Splash1199
  • 379
  • 3
  • 14
3
votes
1 answer

Tidy repeated intraclass correlations for multiple readers

In my dataset, I have 5 readers who have classified tests (as either 0, 1 or 2) repeatedly over multiple days. On each day, only 2-3 readers out of the 5 actually classified tests. library(tidyverse) library(broom) df <- tibble(day = rep(1:10,10))…
Peter MacPherson
  • 683
  • 1
  • 7
  • 17
3
votes
0 answers

Convert mgcv or gamm4 gam/bam output to dataframe

The broom package has a great tidy() function for the summary results of simple linear models such as those generated by lm(). However, tidy() does not work for mgcv::bam(), mgcv::gam() or gamm4::gamm4. The bam below produces the…
Adam_G
  • 7,337
  • 20
  • 86
  • 148
3
votes
2 answers

how to compute regressions by group with lm, do, broom and dplyr?

Consider this simple example > dataframe <- data_frame(id = c(1,2,3,4,5,6), + group = c(1,1,1,2,2,2), + value = c(200,400,120,300,100,100)) > dataframe # A tibble: 6 x 3 id group value
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
3
votes
4 answers

Fit model using each predictor columns indiviually store results in dataframe

I have a dataframe with one column of a response variable, and several columns of predictor variables. I want to fit models for the response variable using each of the predictor variables separately, finally creating a dataframe that contains the…
nofunsally
  • 2,051
  • 6
  • 35
  • 53
3
votes
1 answer

Stratified permutation with bootstrap

I am experiencing issues in trying to stratify permutations. My data look like this : gender party value 1 F Democrat 762 2 M Democrat 484 3 F Independent 327 4 M Independent 239 5 F …
giac
  • 4,261
  • 5
  • 30
  • 59