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
2
votes
2 answers

R nested models: create column of model formulas

How can I create a column of formulas (such as y ~ x or y ~ log(x) or ...) from a nested dataframe of models? In attempt below, the model column contains the model with the largest value of R squared. The purpose of creating a column of model…
Vlad
  • 3,058
  • 4
  • 25
  • 53
2
votes
1 answer

using plotmath in ggrepel labels

I am trying to create a plot where I want to show all coefficients from my linear model and their respective statistical details attached at each point using ggrepel package. I have managed to create the basic plot, but what I haven't been able to…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
2
votes
1 answer

time series regression by group with newey-West standard errors plus getting R2

I have a data.table with annual returns and 2 explanatory variables for 25 different equity portfolios. I would like to estimate the same lm model for each of 25 portfolios where the standard errors are NeweyWest-corrected. So far, I'm runnning the…
DeepBlue
  • 83
  • 8
2
votes
1 answer

Error when using broom (augment) and modelr (crossv_kfold) on glm with an offset term

I am trying to fit a poisson regression model on a k-fold cross validated data set using modelr's crossv_kfold and then get predictions using broom's augment function. In the data I'm modeling I have a count I'm trying to predict, but it needs to be…
Bart Spoon
  • 93
  • 1
  • 7
2
votes
2 answers

Run multiple chisq-tests on one dataset with purrr

I'm very new to the world of R. I have the following test data: A<-tibble(parasite=sample(0:1,10,rep=TRUE),L1=sample(0:1,10,rep=TRUE), L2=sample(0:1,10,rep=TRUE),L3=sample(0:1,10,rep=TRUE), L4=sample(0:1,10,rep=TRUE)) Looks like: parasite L1…
Fishguy
  • 35
  • 4
2
votes
1 answer

Tidying objects with broom created with lmerTest does not work

I recently updated to R version 3.5.0 and R Studio version 1.1.447 (Mac El Capitan 10.11.6). When I try to tidy (with the package broom) an object created with the package 'lmerTest' I get an error message: Error in vector(type, length) : …
Benjamin Telkamp
  • 1,451
  • 2
  • 17
  • 31
2
votes
2 answers

bootstrap by group in tibble

Suppose I have a tibble tbl_ tbl_ <- tibble(id = c(1,1,2,2,3,3), dta = 1:6) tbl_ # A tibble: 6 x 2 id dta 1 1 1 2 1 2 3 2 3 4 2 4 5 3 5 6 3 6 There are 3 id groups. I want to…
rosima
  • 23
  • 2
2
votes
4 answers

Using tidytext and broom but not finding tidier for LDA_VEM

The tidytext book has examples with a tidier for topicmodels: library(tidyverse) library(tidytext) library(topicmodels) library(broom) year_word_counts <- tibble(year = c("2007", "2008", "2009"), + word = c("dog", "cat",…
Isaiah
  • 2,091
  • 3
  • 19
  • 28
2
votes
2 answers

dplyr with stats test

I have the follow data setup library(dplyr) library(broom) pop.mean = 0.10 df = data.frame( trial = as.integer(runif(1000, min = 5, max = 20)), success = as.integer(runif(1000, min = 0, max = 20)), my.group =…
iboboboru
  • 1,112
  • 2
  • 10
  • 21
2
votes
1 answer

Inflation function in R broom package not working as expected

I expect the below code library(dplyr) library(broom) d <- data.frame(a = 1:3, b = 8:10) d %>% inflate(x = c("apple", "orange"), y = c("car", "boat")) to give me a 12 x 4 data frame that looks like this: ## 1 apple boat 1 8 ## 2 apple boat 2 9 ##…
2
votes
1 answer

Tidy output from many single-variable models using purrr, broom

I have a dataframe that comprises of a binary outcome column (y), and multiple independent predictor columns (x1, x2, x3...). I would like to run many single-variable logistic regression models (e.g. y ~ x1, y ~ x2, y ~ x3), and extract the…
Peter MacPherson
  • 683
  • 1
  • 7
  • 17
2
votes
1 answer

Function for Tidy chisq.test Output for Visualizing or Filtering P-Values

For data... library(productplots) library(ggmosaic) For code... library(tidyverse) library(broom) I'm trying to create tidy chisq.test output so that I can easily filter or visualize p-values. I'm using the "happy" dataset (which is…
Mike
  • 2,017
  • 6
  • 26
  • 53
2
votes
1 answer

Fitting several regression models after group_by with dplyr and applying the resulting models into test sets

I have a big dataset that I want to partition based on the values of a particular variable (in my case lifetime), and then run logistic regression on each partition. Following the answer of @tchakravarty in Fitting several regression models with…
morfara
  • 190
  • 3
  • 16
2
votes
1 answer

Broom::tidy error with dataframe of nnet::multinom models

I am generating multinom models using nnet, with a model fitted for each city in the dataset. When I attempt to use tidy with these models, I get the following error: Error in probs[i, -1, drop = FALSE] : subscript out of bounds However, if I…
nofunsally
  • 2,051
  • 6
  • 35
  • 53
2
votes
1 answer

R - ggplot geom_smooth facet_grid CI not showing

I am having a hard time understanding why the confidence intervals are not showing with my data. When I reproduce my code on another dataset, the code seems to work fine. For example, on mtcars The code is mtols = mtcars %>% group_by(am) %>% do(lm0…
giac
  • 4,261
  • 5
  • 30
  • 59