@@ -50,50 +50,13 @@ outstandR <- function(AC.IPD, BC.ALD, strategy, CI = 0.95, ...) {
5050 if (! inherits(strategy , " strategy" ))
5151 stop(" strategy argument must be a class strategy." )
5252
53- # select data according to formula
54- ipd <- model.frame(strategy $ formula , data = AC.IPD )
55-
56- term.labels <- attr(terms(strategy $ formula ), " term.labels" )
57- mean_names <- paste0(" mean." , term.labels )
58- sd_names <- paste0(" sd." , term.labels )
59- term_names <- c(mean_names , sd_names )
60-
61- # remove treatment labels
62- term_names <- sort(term_names [! grepl(pattern = " trt" , term_names )])
63-
64- # replace outcome variable name
65- response_var <- all.vars(strategy $ formula )[1 ]
66- response_names <- gsub(pattern = " y" , replacement = response_var ,
67- x = c(" y.B.sum" , " y.B.bar" , " N.B" , " y.C.sum" , " y.C.bar" , " N.C" ))
68-
69- keep_names <- c(term_names , response_names )
70-
71- ald <- BC.ALD [keep_names ]
53+ ipd <- prep_ipd(strategy $ formula , AC.IPD )
54+ ald <- prep_ald(strategy $ formula , BC.ALD )
7255
73- AC_outstandR <- IPD_stats(strategy , ipd = ipd , ald = ald , ... )
74- BC_outstandR <- ALD_stats(ald = ald )
75-
76- upper <- 0.5 + CI / 2
77- ci_range <- c(1 - upper , upper )
78-
79- contrasts <- list (
80- AB = AC_outstandR $ mean - BC_outstandR $ mean ,
81- AC = AC_outstandR $ mean ,
82- BC = BC_outstandR $ mean )
83-
84- contrast_variances <- list (
85- AB = AC_outstandR $ var + BC_outstandR $ var ,
86- AC = AC_outstandR $ var ,
87- BC = BC_outstandR $ var )
88-
89- contrast_ci <- list (
90- AB = contrasts $ AB + qnorm(ci_range )* as.vector(sqrt(contrast_variances $ AB )),
91- AC = contrasts $ AC + qnorm(ci_range )* as.vector(sqrt(contrast_variances $ AC )),
92- BC = contrasts $ BC + qnorm(ci_range )* as.vector(sqrt(contrast_variances $ BC )))
56+ AC_stats <- IPD_stats(strategy , ipd = ipd , ald = ald , ... )
57+ BC_stats <- ALD_stats(ald = ald )
9358
94- stats <- list (contrasts = contrasts ,
95- variances = contrast_variances ,
96- CI = contrast_ci )
59+ stats <- contrast_stats(AC_stats , BC_stats , CI )
9760
9861 structure(stats ,
9962 CI = CI ,
0 commit comments