Skip to content

Commit

Permalink
Fixes for issue #67
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlenth committed Aug 19, 2024
1 parent f74123e commit e40ee95
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit e40ee95

Please sign in to comment.