plot.unvs.med: Visualization of Mediation Effects

plot.unvs.medR Documentation

Visualization of Mediation Effects

Description

This function is applied to the resulting object from function FormalEstmed to make the plot of the mediation effects. The plot is shown in boxplot.

Usage

## S3 method for class 'unvs.med'
 plot(x, scale = "RD", type = c("PNDE", "TNIE"), ...)

Arguments

x

a resulting object of class "unvs.med" from function FormalEstmed.

scale

a character variable of the effect scales. It may include more than one element. The default is "RD".

type

a character variable of the effect types. The character can contain any types. The default is c("PNDE", "TNIE").

...

additional parameters passed to "plot".

Details

(1) For instance, for parameter scale, users can specify it as "RD", c("RD"), c("RD", "OR"), c("RD", "OR", "RR"), etc. regardless of the order and quantity. Besides, if scale equals to "all", "ALL" or "All", then effects on three scales will be output (2) For type, the element is arbitrary, it may include any types of effects users are interested.

Value

No return value, called for making a plot.

Examples


# Running formal estimation
data(testdata)
med_model=glm(med~exp+C1+C2+C3, data=testdata, family=binomial) # Fitting mediator's model
out_model=lm(out~med*exp+C1+C2+C3, data=testdata) # Fitting outcome's model
r1 = FormalEstmed (med_model=med_model, out_model=out_model,
data=testdata, exposure = "exp") # Running formal estimation via bootstrapping

# Plot examples
plot(r1) # Plot of the default settings (plot PNED and TNDE on RD scales).
plot(r1,"OR") # Plot PNDE and TNIE on OR scales.
plot(r1,c("RD", "OR")) # Plot PNED and TNDE on RD and OR scales.
# Plot five types of the effects on RD and OR scales:
plot(r1,c("RD", "OR"), c("TE","PNDE", "TNDE", "PNIE", "TNIE"))
plot(r1,c("RD", "RR"), "all") # Plot all the effects on RD and RR scales.
plot(r1, scale=c("RD", "OR", "RR"), type="all") # Plot all the effects on all scales.



unvs.med documentation built on June 8, 2025, 10:15 a.m.