Description Usage Arguments Examples
plmed
is used to fit mediation effects for a continuous outcome
given a single continuous mediator, binary exposure, and set of
variables which adjust for confounding. It is assumed that the
outcome and mediator models are linear and the exposure model is
logisitic. It uses a G-estimation procedure to estimate direct and
indirect effects, with a Bias-Reduced strategy used to estimate
nuisance parameters. As with the plmed
function,
the confounder set is the union terms in the exposure.formula
,
mediator.formula
, and outcome.formula
. Missing data behaviour is always na.action=na.omit
.
1 2 3 4 5 6 7 8 | G_estimation(
exposure.formula,
mediator.formula,
outcome.formula,
exposure.family = "gaussian",
data,
weights
)
|
exposure.formula |
an object of class " |
mediator.formula |
an object of class " |
outcome.formula |
an object of class " |
exposure.family |
link function for the exposure model, can be can be a character string naming a family function, a family function or the result of a call to a family function. (See family for details of family functions.) |
data |
an optional data frame, list or environment
(or object coercible by |
weights |
an optional vector of ‘prior weights’ to be used in
the fitting process. Should be #' @return An object of class |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #Example on Generated data
N <- 100
beta <- c(1,0,1) #Some true parameter values
#Generate data on Confounders (Z), Exposure (X)
#Mediator (M), Outcome (Y)
Z <- rnorm(N)
X <- rbinom(N,1,plogis(Z))
M <- beta[1]*X + Z +rnorm(N)
Y <- beta[2]*M + beta[3]*X + Z +rnorm(N)
G_estimation(X~Z,M~Z,Y~Z)
#Example on JobsII data from the mediation package
jobs <- mediation::jobs
Z.formula = c('econ_hard','sex','age','occp',
'marital','nonwhite','educ','income')
plmed(reformulate(Z.formula,response='treat'),
reformulate(Z.formula,response='job_seek'),
reformulate(Z.formula,response='depress2'),
data=jobs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.