Skip to content

[821] Feature Request: Add weights option to ancova #1412

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

Merged
merged 2 commits into from
Apr 7, 2025

Conversation

yurovska
Copy link
Contributor

Fixes #821

Copy link
Contributor

github-actions bot commented Mar 29, 2025

✅ All contributors have signed the CLA
Posted by the CLA Assistant Lite bot.

@yurovska
Copy link
Contributor Author

yurovska commented Mar 29, 2025

Random example:

adsl <- tern::tern_ex_adsl

adlb <- tern::tern_ex_adlb %>%
  mutate(
    CHG = if_else(AVISITN > 0, AVAL - BASE, NA_real_, NA_real_)
  ) %>%
  filter(
    PARAMCD == "ALT"
    & AVISIT == "WEEK 5 DAY 36"
  )

lyt <- basic_table(show_colcounts = TRUE) %>%
  split_cols_by(
    var = "ARM",
    ref_group = "B: Placebo"
  ) %>%
  split_rows_by(
    var = "PARAMCD",
    labels_var = "PARAM",
    label_pos = "topleft",
    split_label = "Parameter",
    section_div = " "
  ) %>%
  summarize_ancova(
    vars = "CHG",
    variables = list(
      arm = "ARM",
      covariates = c("BASE", "SEX", "ARM")
    ),
    conf_level = 0.95,
    var_labels = "",
    show_labels = "hidden",
    weights_emmeans = "proportional"
  )

build_table(lyt, adlb, alt_counts_df = adsl)

@shajoezhu
Copy link
Contributor

tracking downstream checks at insightsengineering/scda.test#192

Copy link
Contributor

@shajoezhu shajoezhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @yurovska , can you please fix the lintr issue.

@shajoezhu
Copy link
Contributor

Random example:

adsl <- tern::tern_ex_adsl

adlb <- tern::tern_ex_adlb %>%
  mutate(
    CHG = if_else(AVISITN > 0, AVAL - BASE, NA_real_, NA_real_)
  ) %>%
  filter(
    PARAMCD == "ALT"
    & AVISIT == "WEEK 5 DAY 36"
  )

lyt <- basic_table(show_colcounts = TRUE) %>%
  split_cols_by(
    var = "ARM",
    ref_group = "B: Placebo"
  ) %>%
  split_rows_by(
    var = "PARAMCD",
    labels_var = "PARAM",
    label_pos = "topleft",
    split_label = "Parameter",
    section_div = " "
  ) %>%
  summarize_ancova(
    vars = "CHG",
    variables = list(
      arm = "ARM",
      covariates = c("BASE", "SEX", "ARM")
    ),
    conf_level = 0.95,
    var_labels = "",
    show_labels = "hidden",
    weights_emmeans = "proportional"
  )

build_table(lyt, adlb, alt_counts_df = adsl)

i would like also suggest adding this example with an snapshot to the scda.test

@shajoezhu shajoezhu added the sme label Mar 30, 2025
@yurovska
Copy link
Contributor Author

hi @yurovska , can you please fix the lintr issue.

Fixed

@yurovska
Copy link
Contributor Author

i would like also suggest adding this example with an snapshot to the scda.test

@shajoezhu See my comment within insightsengineering/scda.test#192

@shajoezhu shajoezhu enabled auto-merge (squash) April 7, 2025 02:17
Copy link
Contributor

@shajoezhu shajoezhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! Thanks a lot @yurovska

@shajoezhu shajoezhu merged commit 0af4c5f into insightsengineering:main Apr 7, 2025
28 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add weights option to ancova
2 participants