GithubHelp home page GithubHelp logo

nlme and geepack about broom HOT 6 CLOSED

tidymodels avatar tidymodels commented on August 20, 2024 1
nlme and geepack

from broom.

Comments (6)

mmulvahill avatar mmulvahill commented on August 20, 2024 4

If so, consider nlme::gls as well.

from broom.

strengejacke avatar strengejacke commented on August 20, 2024 1

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.

alexpghayes avatar alexpghayes commented on August 20, 2024 1

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.

rubenarslan avatar rubenarslan commented on August 20, 2024

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.

sebpardo avatar sebpardo commented on August 20, 2024

Expanding this package to work with nlme::lme and nlme::gls would be great!

from broom.

github-actions avatar github-actions commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.