plot.unvs.med | R Documentation |
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.
## S3 method for class 'unvs.med'
plot(x, scale = "RD", type = c("PNDE", "TNIE"), ...)
x |
a resulting object of class |
scale |
a character variable of the effect scales. It may include more than one element.
The default is |
type |
a character variable of the effect types. The character can contain any types.
The default is |
... |
additional parameters passed to "plot". |
(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.
No return value, called for making a plot.
# 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.