Description Usage Arguments Value See Also Examples
View source: R/hbarDensityModel.R
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
.
1 2 3 |
data |
|
Anodes |
Column names or indices in |
Wnodes |
Column names or indices in |
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
|
h.gstar_GenericModel |
... |
lbound |
lower bounds on estimated cumulative probabilities for |
n_MCsims |
... |
obs.wts |
... |
rndseed |
... |
verbose |
... |
A named list with 3 items containing the estimation results for:
h_gstar
- A vector of likelihood prediction for P(A=a|W=w)
where a is generated under the
user-specified intervention.
OData.gstar
- A DatKeepClassclass
object,where outcomes are generated under intervention f_gstar
.
genericmodels.gstar
- A GenericModel
class object that defines and models P(A=a|W=w)
.
tmleCom_Options
, DatKeepClass
, RegressionClass
, GenericModel
,
ContinModel
, CategorModel
, tmleCommunity
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.