Comments (11)
Closed in #597! Thanks @vincentarelbundock!
from broom.
I also think it would be useful if glance output included nobs. It looks like glance.stanreg already does:
https://github.com/dgrtwo/broom/blob/master/R/rstanarm_tidiers.R
from broom.
Just adding my vote to this feature. I think in most fields, it is standard to report the N as one of the summary statistics.
from broom.
hello there! is there a fix for that very important feature?
thanks!!
from broom.
I'd be willing to this in a tryCatch to finish_glance
to pick up an n
column for relevant models. The question then is how many models actually implement nobs()
methods.
I'm hesitant to report counts for each factor level in glance()
because this is moving more into data summarizing than properties of a model. If a tidy()
method doesn't already inherit this information from summary()
or whatnot I don't think it's worth the effort to try implement this consistently across tidiers. Also, skimr::skim()
is fantastic for this sort of thing.
from broom.
I'm building a regression summary package built on broom and users are requesting this feature. It's pretty important to me, and I would be willing to do it if you tell me about your implementation preferences.
To answer your question, a lot of models actually implement the nobs
method. I went through every extract
method in the texreg
package. I may have missed a couple, but the models not listed below should work with nobs
:
#default
stats::nobs(model)
#felm
summary(model)$N
#censReg
summary(model)$nobs
#btergm
#mbtergm
model@nobs
#betaor
#betamfx
model$fit$nobs
#averaging
#model.selection (MuMIn)
as.numeric(attr(model, 'nobs'))
#sienaFit
model$n
#zeroinfl
summary(model)$n
#fGARCH
length(model@data)
# gel
NROW(model$gt)
# lme4
dim(model.frame(model))[1]
#lmrob
#systemfit
#lmRob
length(model$residuals)
#logitmfx
#probitmfx
#negbinirr
#negbinmfx
nrow(model$fit$model)
#lrm
model$stats[1]
#mlogit
#plm
#pmg
#rq
#summary.lm
nrow(summary(model)$residuals)
#mnlogit
s$model.size$N
#multinom
#sarlm
nrow(summary(model$fitted.values))
#pgmm
attr(summary(model), 'pdim')$nT$N
#simex
length(model$model$residuals)
#survreg
length(model$linear.predictors)
#zelig
nrow(model$data)
#pglm
length(model$gradientObs[, 1])
from broom.
@alexpghayes One possible design that I would be willing to implement:
For each element of the list above which are not compatible with nobs
, extract the value explicitly in the model-specific glance function.
Modify the finish_glance
function. If 'n' %in% names(ret)
, then tryCatch(stats::nobs)
This is a bit more work (which I am willing to do), but it's explicit, and would avoid unexpected side effects from having a bunch of ifelse statements.
from broom.
Sounds simpler to just implement nobs()
methods for these internally, where they don't exist. Ideally these would be offered upstream to the respective package maintainers, but there's nothing stopping these being in broom if they are not wanted or maintainers are unresponsive. Using nobs()
makes it simpler/safer to implement return of number of observations in glance
.
from broom.
Sure. I'm happy to write a bunch of nobs
methods if people find those useful. There's also a discussion about how these methods would be used in my WIP PR: #594
Basically,
- Each
glance
function calls its ownnobs()
finish_glance
callsnobs()
for all of them, as it currently does forAIC
,BIC
, etc.
from broom.
I'm in the process of checking every model object for which broom
offers a glance
function to see if they work with stats::nobs
. I'm also writing new methods for those that don't. The results are collected in this Gist:
https://gist.github.com/vincentarelbundock/24bedac98499181790aab230cc5b74bc
from broom.
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
from broom.
Related Issues (20)
- tidy.anova fails with long predictor names (two lines?): Logical subscript `idx` must be size 1 or 2, not 3. HOT 3
- tidy.varest contains wrong (repeated) coefficients? HOT 4
- transition to cli errors
- add / polish alt text
- Regression Model Accuracy Metrics for Objects of class oohbchoice HOT 2
- No tidy method for objects of class npregression HOT 2
- Issues regarding CI computing for lm.beta models HOT 2
- augment error with `na.action = na.exclude` in `lm` HOT 1
- add conf.int and exponentiate arguments to `tidy.cch()`
- Error: No tidy method for objects of class npregression HOT 2
- Possible bug with `tidy() ` function on `lm.beta` object HOT 3
- augment() fails HOT 3
- address GHA failures re: minimum R version HOT 1
- Bug in `tidy.survfit()` coming in the next release of the {survival} pkg HOT 5
- Create tidy method HOT 5
- Support for glmtoolbox (GEE) HOT 2
- Allow choosing the type of residuals in `tidy.betareg()` HOT 3
- GHA failure re: archived package HOT 1
- dependency install errors on GHA HOT 3
- Release broom 1.0.6 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from broom.