View source: R/calculate_density_ratio_dnorm.R
| calculate_density_ratio_dnorm | R Documentation |
Computes the ratio of two conditional densities of M evaluated at treatment
levels a_0 and 1 - a_0. Let mp(M) \setminus A denote the
Markov pillow of M excluding the treatment A. The density ratio is defined as
\frac{p(M \mid mp(M) \setminus A,\, A = a_0)}{p(M \mid mp(M) \setminus A,\, A = 1 - a_0)}.
The conditional density of M is modelled as follows: Gaussian for univariate or multivariate continuous M (via linear regression), Bernoulli for binary M (via logistic regression), and multivariate Gaussian for multivariate continuous M (via separate linear regressions with a shared residual covariance). Multivariate variables with binary elements are not supported.
calculate_density_ratio_dnorm(a0, M, graph, treatment, data, formula = NULL)
a0 |
Numeric. The reference treatment level; must be 0 or 1. The
density ratio is computed as |
M |
A character string naming the variable for which the density ratio
is computed. May refer to a univariate or multivariate vertex as defined in
|
graph |
A graph object created by |
treatment |
A character string naming the binary treatment variable A in
|
data |
A data frame containing all variables in the graph. |
formula |
An optional named list of regression formulas, where each name
is a variable name and the corresponding value is the formula to use for
that variable's regression on its Markov pillow. Variables not included in
this list are regressed using all Markov pillow variables as predictors.
See |
A numeric vector of length nrow(data) containing the
density ratio for each observation. Returns a vector of ones if the
treatment A is not in the Markov pillow of M (i.e., the ratio is
identically 1).
Currently only supports binary treatment coded as 0/1. Multivariate variables with binary elements are not supported.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.