Skip to content

Commit 2b4adee

Browse files
REsolving merge conflict
2 parents efdd70b + 3893af8 commit 2b4adee

File tree

6 files changed

+105
-8
lines changed

6 files changed

+105
-8
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# R specific hooks: https://github.com/lorenzwalthert/precommit
33
repos:
44
- repo: https://github.com/lorenzwalthert/precommit
5-
rev: v0.4.3.9003
5+
rev: v0.4.3.9007
66
hooks:
77
- id: style-files
88
args: [--style_pkg=styler, --style_fun=tidyverse_style, --ignore-start="^# Generated by using Rcpp"]

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: TrialEmulation
22
Title: Causal Analysis of Observational Time-to-Event Data
3-
Version: 0.0.4.3
3+
Version: 0.0.4.4
44
Authors@R: c(
55
person("Isaac", "Gravestock", , "isaac.gravestock@roche.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-0283-2065")),
@@ -57,6 +57,11 @@ Roxygen: list(markdown = TRUE)
5757
RoxygenNote: 7.3.2.9000
5858
Collate:
5959
'RcppExports.R'
60+
<<<<<<< HEAD
61+
=======
62+
'lr_utils.R'
63+
'utils.R'
64+
>>>>>>> 3893af84c0c2b9fe7ae5f4b4c1bc91716d3b27e1
6065
'bootstrap.R'
6166
'calculate_weights.R'
6267
'data.R'
@@ -68,7 +73,6 @@ Collate:
6873
'expand_trials.R'
6974
'generics.R'
7075
'initiators.R'
71-
'lr_utils.R'
7276
'te_model_fitter.R'
7377
'te_outcome_model.R'
7478
'te_datastore.R'
@@ -85,5 +89,4 @@ Collate:
8589
'te_datastore_duckdb.R'
8690
'te_parsnip.R'
8791
'te_stats_glm_logit.R'
88-
'utils.R'
8992
'weighting.R'

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# TrialEmulation 0.0.4.3
1+
# TrialEmulation 0.0.4.4
22

33
* Update tests for duckdb 1.2.0 changes to sampling.
44

R/trial_sequence.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,12 @@ setMethod(
514514
period = as_formula(trial_period_terms, add = collection),
515515
stabilised = as_formula(get_stabilised_weights_terms(object), add = collection)
516516
)
517-
adjustment <- unique(c(all.vars(formula_list$adjustment), all.vars(formula_list$stabilised)))
517+
treatment <- all.vars(formula_list$treatment)
518+
adjustment <- setdiff(
519+
unique(c(all.vars(formula_list$adjustment), all.vars(formula_list$stabilised))),
520+
treatment
521+
)
522+
518523
assert_names(
519524
adjustment,
520525
subset.of = colnames(object@data@data),
@@ -619,6 +624,7 @@ get_stabilised_weights_terms <- function(object) {
619624
stabilised_terms
620625
}
621626

627+
# Update outcome model (formulas generally and variables in stabilised models)
622628
update_outcome_formula <- function(object) {
623629
assert_class(object, "trial_sequence")
624630

@@ -638,7 +644,7 @@ update_outcome_formula <- function(object) {
638644
object@outcome_model@formula <- outcome_formula
639645

640646
object@outcome_model@adjustment_vars <- unique(
641-
c(all.vars(formula_list$adjustment), all.vars(formula_list$stabilised))
647+
c(object@outcome_model@adjustment_vars, all.vars(formula_list$stabilised))
642648
)
643649

644650
object

man/weight_func_bootstrap.Rd

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-trial_sequence.R

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,29 @@ test_that("stabilised weight terms are included in outcome model", {
500500
)
501501
})
502502

503-
# Expand
503+
504+
test_that("interaction terms work as expected", {
505+
result <- trial_sequence("PP") |>
506+
set_data(data_censored) |>
507+
set_outcome_model(adjustment_terms = ~ assigned_treatment * x2)
508+
509+
expect_equal(
510+
result@outcome_model@formula,
511+
outcome ~ assigned_treatment + x2 + followup_time + I(followup_time^2) +
512+
trial_period + I(trial_period^2) + assigned_treatment:x2,
513+
ignore_formula_env = TRUE
514+
)
515+
expect_equal(result@outcome_model@treatment_var, "assigned_treatment")
516+
expect_equal(result@outcome_model@adjustment_vars, "x2") # shouldn't include treatment
517+
expect_equal(
518+
result@outcome_model@adjustment_terms, # can include treatment
519+
~ assigned_treatment * x2,
520+
ignore_formula_env = TRUE
521+
)
522+
})
523+
524+
# Expand ---
525+
504526
test_that("weights are 1 when not calculated by calculate_weights", {
505527
trial_ex <- TrialEmulation::trial_example
506528

0 commit comments

Comments
 (0)