Comments (6)
If so, consider nlme::gls as well.
from broom.
Here are my tidiers for lme and gls, but only for fixed effects
#' @importFrom broom tidy
#' @importFrom tibble has_name
#' @importFrom sjstats p_value
#' @importFrom nlme intervals
tidy_lme_model <- function(model, ci.lvl) {
# get tidy summary. for lme, this excludes CI,
# so we compute them separately
dat <- broom::tidy(model, conf.int = TRUE, conf.level = ci.lvl, effects = "fixed")
ci <- as.data.frame(nlme::intervals(model, level = ci.lvl, which = "fixed")$fixed)
dat$conf.low <- ci$lower
dat$conf.high <- ci$upper
# see if we have p-values. if not, add them
if (!tibble::has_name(dat, "p.value"))
dat$p.value <- sjstats::p_value(model)[["p.value"]]
dat
}
#' @importFrom sjmisc var_rename
#' @importFrom nlme intervals
#' @importFrom dplyr select
#' @importFrom tibble rownames_to_column
tidy_gls_model <- function(model, ci.lvl) {
# get tidy summary. for lme, this excludes CI,
# so we compute them separately
dat <- as.data.frame(summary(model)$tTable)
ci <- as.data.frame(nlme::intervals(model, level = ci.lvl, which = "coef")$coef)
dat$conf.low <- ci$lower
dat$conf.high <- ci$upper
sjmisc::var_rename(
dat,
Value = "estimate",
Std.Error = "std.error",
`t-value` = "statistic",
`p-value` = "p.value"
) %>%
tibble::rownames_to_column("term")
}
from broom.
At some point we gained tidy.geeglm()
. Not sure if there are unmet requests for nlme tidiers in this thread, but if there are they belong in broom.mixed
per #329. Linking in bbolker/broom.mixed#2 just in case.
from broom.
Here's what I currently substitute for your tidy.lme because it gives no confidence intervals. HTH, can also try a PR.
my_tidy.lme = function(fit, effects = "fixed") {
if(effects == "fixed") {
confintervals = data.frame(nlme::intervals(fit)$fixed)
confintervals$term = rownames(confintervals)
mydf = confintervals[confintervals$term != "(Intercept)", ]
names(mydf) = c("conf.low", "estimate", "conf.high", "term")
pvals = data.frame(nlme:::summary.lme(fit)$tTable)
names(pvals) = c("estimate","std.error","df","statistic","p.value")
pvals$term = rownames(pvals)
mydf = merge(mydf, pvals[, c("term","p.value","std.error","statistic")], by = 'term')
rownames(mydf) = NULL
mydf = mydf[, c("term", "estimate", "std.error", "statistic", "p.value", "conf.low","conf.high")]
mydf
} else {
stop("Only fixed effects implemented.")
}
}
from broom.
Expanding this package to work with nlme::lme and nlme::gls would be great!
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.