Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nlme and geepack #28

Closed
sahirbhatnagar opened this issue Feb 24, 2015 · 6 comments
Closed

nlme and geepack #28

sahirbhatnagar opened this issue Feb 24, 2015 · 6 comments
Assignees

Comments

@sahirbhatnagar
Copy link

Would you consider expanding this package to work on objects of class lme (from nlme) and objects of type geeglm (from geepack)?

@sahirbhatnagar sahirbhatnagar changed the title nlme and geepacl nlme and geepack Feb 24, 2015
@dgrtwo dgrtwo self-assigned this Feb 24, 2015
@rubenarslan
Copy link

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.")
  }
}

@mmulvahill
Copy link

If so, consider nlme::gls as well.

@sebpardo
Copy link

sebpardo commented Dec 7, 2016

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

@strengejacke
Copy link

strengejacke commented Oct 2, 2017

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")
}

@alexpghayes
Copy link
Collaborator

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.

@github-actions
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants