| calc.weights | R Documentation |
The weights are calculated according to formula (14) in Schomaker et al. (2023).
calc.weights(X, Anodes = NULL, Ynodes = NULL, Lnodes = NULL, Cnodes = NULL,
abar = NULL, times = length(Anodes), c = 0.01, screen = FALSE,
survival = FALSE, eps = 1e-10, zero = 0,
d.method = c("binning", "parametric", "hal_density", "hazardbinning"),
z.method = c("density", "eps"), w.function = "gal_ga",
for.sgf = TRUE,
verbose = TRUE, ...)
X |
A data frame, following the time-ordering of the variables. |
Anodes |
A character string of column names in |
Ynodes |
A character string of column names in |
Lnodes |
A character string of column names in |
Cnodes |
A character string of column names in |
abar |
Numeric vector or matrix of intervention values. See Details. |
times |
Numeric value specifying for how many time points the weights should be calculated. |
c |
A numeric value (or vector) specifying the threshold(s) below which the weights correspond to the density ratios, rather than 1. |
screen |
Logical. If |
survival |
Logical. If |
eps |
A numeric value specifying epsilon if |
zero |
A numeric value specifying which actual number is considered to be "zero" in the denominator. |
d.method |
A string specifying which method should be used to estimate the conditional density. One of |
z.method |
A string specifying the method which should be used if the denominator is zero: The default is |
w.function |
A string specifying the weight function which specifies how the conditional densities from numerator and denominator as well as c should be combined. Currently, |
for.sgf |
Logical. If TRUE, weights are organized such that they fit the order required for |
verbose |
Logical. If |
... |
Further arguments to be passed on. |
Calculates the outcome weights as described in formula (15) of Schomaker et al. (2024).
For details on the specific conditional density estimation methods specified under d.method, see the manual at https://github.com/MichaelSchomaker/CICI.
In survival settings, past censoring and outcome nodes are omitted from the formulae. If censoring is present without a survival setting (e.g. Cnodes describe drop-outs and Y is a continuous outcome), then survival should be set as FALSE.
An object of class Yweights. This is a named list of length of c; each list entry is another list of length(number of time points); each entry is a matrix of size n times I (n=sample size; I=number of Interventions).
Michael Schomaker
Schomaker M, McIlleron H, Denti P, Diaz I. (2024) Causal Inference for Continuous Multiple Time Point Interventions, Statistics in Medicine, 43:5380-5400, see also https://arxiv.org/abs/2305.06645.
data(EFV)
w <- calc.weights(X=EFV, Lnodes = c("sex", "metabolic",
"log_age", "NRTI" ,"weight.0",
"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"),
d.method="parametric", abar=seq(0,5,1), c=0.01)
summary(w)
# w can now be used under 'Yweights' in sgf()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.