Skip to content

Commit

Permalink
Rvlenth main (#70)
Browse files Browse the repository at this point in the history
close #66 
close #67

---------

Co-authored-by: Russell V. Lenth <[email protected]>
  • Loading branch information
shajoezhu and rvlenth authored Aug 21, 2024
1 parent f1d62b1 commit a1da306
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Depends:
tern (>= 0.9.5)
Imports:
checkmate (>= 2.1.0),
emmeans (>= 1.4.5),
emmeans (>= 1.10.4),
formatters (>= 0.5.8),
geeasy,
geepack,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# tern.gee 0.1.4.9004

* Up version `emmeans` package version to 1.10.4.

# tern.gee 0.1.4

* Change package maintainer to Joe Zhu.
Expand Down
8 changes: 5 additions & 3 deletions R/lsmeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @param conf_level (`proportion`)\cr confidence level
#' @param weights (`string`)\cr type of weights to be used for the least square means,
#' see [emmeans::emmeans()] for details.
#' @param specs (`string` or `formula`) specifications passed to [emmeans::emmeans()]
#' @param ... additional arguments for methods
#'
#' @return A `data.frame` with least-square means and contrasts. Additional
Expand All @@ -21,6 +22,7 @@
lsmeans <- function(object,
conf_level = 0.95,
weights = "proportional",
specs = object$vars$arm,
...) {
UseMethod("lsmeans", object)
}
Expand All @@ -30,8 +32,8 @@ lsmeans <- function(object,
lsmeans.tern_gee_logistic <- function(object,
conf_level = 0.95,
weights = "proportional",
specs = object$vars$arm,
...) {
specs <- as.formula(paste("~", object$vars$arm))
prop_emm <- emmeans::emmeans(
object = object,
specs = specs,
Expand All @@ -41,7 +43,7 @@ lsmeans.tern_gee_logistic <- function(object,
)

prop_df <- cbind(
data.frame(stats::confint(prop_emm))[, c(object$vars$arm, "prob", "SE", "asymp.LCL", "asymp.UCL")],
data.frame(stats::confint(prop_emm))[, c(object$vars$arm, "prob", "SE", "lower.CL", "upper.CL")],
n = as.list(prop_emm)$extras[, ".wgt."]
)
names(prop_df) <- c(object$vars$arm, "prop_est", "prop_est_se", "prop_lower_cl", "prop_upper_cl", "n")
Expand All @@ -57,7 +59,7 @@ lsmeans.tern_gee_logistic <- function(object,
or_df <- or_df[or_df$comparator == ref_level, ]
or_df <- rbind(NA, or_df)
or_df[1L, object$vars$arm] <- ref_level
or_df <- or_df[, c(object$vars$arm, "odds.ratio", "asymp.LCL", "asymp.UCL")]
or_df <- or_df[, c(object$vars$arm, "odds.ratio", "lower.CL", "upper.CL")]
or_df <- cbind(or_df, log(or_df[, -1L]), conf_level)
names(or_df) <- c(
object$vars$arm,
Expand Down
18 changes: 16 additions & 2 deletions man/lsmeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a1da306

Please sign in to comment.