Learn R Programming

CICI (version 0.9.7)

custom.measure: Custom estimands after applying gformula

Description

The default estimate returned by gformula is the expected outcome under the respective intervention strategies abar. custom.measure takes an object of class gformula and enables estimation of other estimands based on the counterfactual datasets produced by gformula (if the option ret=TRUE had been chosen), for example estimands conditional on baseline variables, quantiles instead of expectations, and others.

Usage

custom.measure(X, fun = NULL, cond = NULL, verbose = TRUE, with.se = FALSE,
               cilevel = 0.95, ...)

Value

An object of class gformula. See gformula for details.

Arguments

X

An object of class gformula produced by gformula with option ret=TRUE.

fun

A function to be applied to the outcome(s) of the counterfactual data set.

cond

A string containing a condition to be applied to the counterfactual datasets.

verbose

Logical. TRUE if notes should be printed.

with.se

Logical. TRUE if standard deviation should be calculated and returned.

cilevel

Numeric value between 0 and 1 specifying the confidence level. Defaults to 95%.

...

other parameters to be passed to fun

Details

In settings with censoring, it will often be needed to pass on the option na.rm=T, e.g. for the mean, median, quantiles, and others.

Calculation of the bootstrap standard error (i.e., with.se=T) is typically not needed; but, for example, necessary for the calculations after multiple imputation and hence used by mi.boot.

See Also

see also gformula

Examples

Run this code
# \donttest{
data(EFV)

est <- gformula(X=EFV,
                Lnodes  = c("adherence.1","weight.1",
                            "adherence.2","weight.2",
                            "adherence.3","weight.3",
                            "adherence.4","weight.4"
                ),
                Ynodes  = c("VL.0","VL.1","VL.2","VL.3","VL.4"),
                Anodes  = c("efv.0","efv.1","efv.2","efv.3","efv.4"),
                abar=seq(0,2,1), ret=TRUE
)

est
custom.measure(est, fun=prop,categ=1) # identical
custom.measure(est, fun=prop,categ=0)
custom.measure(est, fun=prop, categ=0, cond="sex==1")
# note: metabolic has been recoded internally (see output above)
custom.measure(est, fun=prop, categ=0, cond="metabolic==0") 
# does not make sense here, just for illustration (useful for metric outcomes)
custom.measure(est, fun=quantile, probs=0.1) 
# }

Run the code above in your browser using DataLab