fitGenericDensity: Define and fit the multivariate conditional density under the...

Description Usage Arguments Value See Also Examples

View source: R/hbarDensityModel.R

Description

Defines and fits regression models for the conditional density P(A=a|W=w) where a is generated under the user- specified arbitrary (can be static, dynamic or stochastic) intervention function f_gstar. Note that A can be multivariate (A[1], ..., A[j]) and each of the compoenents A[i] can be either binary, categorical or continuous. See detailed description in RegressionClass.

Usage

1
2
3
fitGenericDensity(data, Anodes, Wnodes, gform = NULL, f_gstar,
  h.gstar_GenericModel = NULL, lbound = 0.01, n_MCsims = 1,
  obs.wts = NULL, rndseed = NULL, verbose = TRUE)

Arguments

data

data.frame with named columns, containing Wnodes, Anode and Ynode.

Anodes

Column names or indices in data of outcome variables; exposures can be either binary, categorical or continuous.

Wnodes

Column names or indices in data of baseline covariates. Factors are not currently allowed.

gform

Character vector of regression formula for estimating the conditional density of P(A | W)

f_gstar

Either a function or a vector or a matrix/ data frame of counterfactual exposures. See details in function argument f_gstar1 in tmleCommunity.

h.gstar_GenericModel

...

lbound

lower bounds on estimated cumulative probabilities for P(A=a|W=w), default to 0.01

n_MCsims

...

obs.wts

...

rndseed

...

verbose

...

Value

A named list with 3 items containing the estimation results for:

See Also

tmleCom_Options, DatKeepClass, RegressionClass, GenericModel, ContinModel, CategorModel, tmleCommunity

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Not run: 
data(indSample.iid.cA.cY_list)
indSample.iid.cA.cY <- indSample.iid.cA.cY_list$indSample.iid.cA.cY
tmleCom_Options(gestimator = "speedglm__glm", maxNperBin = nrow(indSample.iid.cA.cY),
                bin.method = "dhist", nbins = 8)
options(tmleCommunity.verbose = TRUE)  # Print status messages 

# Define a stochastic intervention
define_f.gstar <- function(shift.rate, ...) {
  eval(shift.rate)
  f.gstar <- function(data, ...) {
    print(paste0("rate of shift: ", shift.rate))
    shifted.new.A <- data[, "A"] - mean(data[, "A"]) * shift.rate
    return(shifted.new.A)
  }
  return(f.gstar)
}
f.gstar <- define_f.gstar(shift.rate = 0.5)

# Under current treatment mechanism g0
h_gN <- fitGenericDensity(data = indSample.iid.cA.cY, Anodes = "A", 
                          Wnodes = c("W1", "W2", "W3", "W4"), 
                          f_gstar = NULL, lbound = 0)$h_gstar
# Under stochastic intervention gstar
h_gstar <- fitGenericDensity(data = indSample.iid.cA.cY, Anodes = "A",
                             Wnodes = c("W1", "W2", "W3", "W4"), 
                             f_gstar = f.gstar, lbound = 0)$h_gstar

## End(Not run)

chizhangucb/tmleCommunity documentation built on May 20, 2019, 3:34 p.m.