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
0
votes
1 answer

Calculate confidence intervals (binomial) within data frame

I want to get the confidence intervals for proportions within my tibble. Is there a way of doing this? library(tidyverse) library(Hmisc) library(broom) df <- tibble(id = c(1, 2, 3, 4, 5, 6), count = c(4, 1, 22, 4545, 33, 23), n =…
william3031
  • 1,653
  • 1
  • 18
  • 39
0
votes
0 answers

Creating an Identification variable to identify observations

Hello I have a data set called "Sample" like this Sample A tibble: 221,088 x 7 gvkey two_digit_sic fyear part1 part2 part3 part4 1 001003 57 1987 0.0317 0.0686 …
Sharif
  • 163
  • 1
  • 9
0
votes
0 answers

Using the coefficients from regression models that use group_by function

I run the following code to generate regression models library (dplyr) fitted_models <- df %>% group_by(sic, fyear) %>% do (model = lm (TACCdTA ~ Inverse_TA + DeL_RevRec + PPEdTA , data = .)) Then to get the coefficients for each sic and…
Sharif
  • 163
  • 1
  • 9
0
votes
1 answer

How to fix "Error in eval(predvars, data, env) : numeric 'envir' arg not of length one" in purrr

I'm bootstrapping well known mtcars dataset and applying logistic regression using glm and purrr::map. Howevever I'm getting Error in eval(predvars, data, env) : numeric 'envir' arg not of length one error I've already tried to apply glm to a…
0
votes
1 answer

Broom::augment() : Is there any way to customize column names or specify output columns?

I want to augment the data frame with .fitted columns from broom::augment() for different lm() models so that I can compare the predictions later. I (re)name() the .fitted column for each model, but augment() also adds .rownames .se.fit, etc.,…
0
votes
1 answer

Unnest and bind nested tibble list-columns

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

Fortify and tidy (from broom) cause polygons to not be correct

I am attempting to use a map of Lesotho and plot various other data on it. The shapefile I pulled is the ESRI file from this link: http://www.mapmaker.com/maplibrary/library/stacks/Africa/Lesotho/index.htm When I import the shapefile via readOGR and…
Liz K
  • 1
0
votes
2 answers

Difference in p-values between summary() vs glance()?

I'm noticing a difference in the p-values when calling summary() on a linear model object versus calling broom::glance(). I think the floating point precision when calling summary() is limited to 2.2e-16 while glance can reach beyond 1e-100. Is my…
philiporlando
  • 941
  • 4
  • 19
  • 31
0
votes
0 answers

boxCox() won't accept linear model created by map() despite being same class?

I have several models that I am trying to generate at once and then run separate boxCox() transformations. But every time I try to run boxCox(), I am getting a strange error. I think it has to do with how the formula changes to .x when using map().…
dylanjm
  • 2,011
  • 9
  • 21
0
votes
1 answer

Why does broom::augment return more rows than input data?

I noticed that while using Broom's augment function, the newly created data frame has more rows than I originally started with. e.g. # Statistical Modeling ## dummy vars library(tidyverse) training_data <- mtcars dummy <- caret::dummyVars(~ ., data…
Doug Fir
  • 19,971
  • 47
  • 169
  • 299
0
votes
1 answer

Extract a sinlge element with unnest from broom::tidy

I want to get a single elemnet from the broom tidy results into an unnested data frame. The table structure is: > zz # A tibble: 1,923 x 5 sys_loc_code data model tidy glance
kray
  • 377
  • 1
  • 3
  • 11
0
votes
0 answers

tidyr applying a regression model with purr and broom

I am using a nested data approach to apply a censored data model to stream clarity data in 1275 streams ~225,000 observations). I have successfully used group_by to group the data set to three hierarchal levels ( HUC4, Major watershed, and Stream……
kray
  • 377
  • 1
  • 3
  • 11
0
votes
1 answer

How to broom::glance or summarize several phylogenetic gls and save as tibble?

I have several phylogenetic GLS and would like to find a better way to summarize the results. I am not using loops to obtain several PGLS since I will be clumping several traits from different matrices. Example below: library(caper) # for the pgls…
Andrés Parada
  • 319
  • 7
  • 21
0
votes
1 answer

RStudio Error with Tidy - Column 6 must be named

I'm trying to use tidy to put a regression result into table format to export to Excel. My codes worked fine last month, but today I got Error: Column 6 must be named. Below is an example: CarReg = lm(formula = speed ~., data = cars) # Standardize…
T-T
  • 693
  • 1
  • 10
  • 24
0
votes
2 answers

rolling regression with confidence interval (tidyverse)

This is related to rolling regression by group in the tidyverse? Consider again this simple example library(dplyr) library(purrr) library(broom) library(zoo) library(lubridate) mydata = data_frame('group' = c('a','a', 'a','a','b', 'b', 'b', 'b'), …
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235