View source: R/e.interaction.plot.R
e.interaction.plot | R Documentation |
plot interaction effect of two exposures
e.interaction.plot(fit, data, exp_1, exp_2)
fit |
Fitted model from function 'plsi.lr.v1' |
data |
Original data set |
exp_1 |
exposure name hoping to be checked |
exp_2 |
exposure name hoping to be checked |
plot of interaction effect of two exposures with others at average level
Yuyan Wang
# example to plot interaction effect of two exposures
data(nhanes.new)
dat <- nhanes.new
# specify variable names and parameters
Y.name <- "log.triglyceride"
X.name <- c("X1_trans.b.carotene", "X2_retinol", "X3_g.tocopherol", "X4_a.tocopherol",
"X5_PCB99", "X6_PCB156", "X7_PCB206",
"X8_3.3.4.4.5.pncb", "X9_1.2.3.4.7.8.hxcdf", "X10_2.3.4.6.7.8.hxcdf")
Z.name <- c("AGE.c", "SEX.Female", "RACE.NH.Black",
"RACE.MexicanAmerican", "RACE.OtherRace", "RACE.Hispanic" )
spline.num = 5
spline.degree = 3
initial.random.num = 1
# run PLSI linear regression
set.seed(2023)
model_1 <- plsi.lr.v1(data = dat, Y.name = Y.name, X.name = X.name, Z.name = Z.name,
spline.num, spline.degree, initial.random.num)
# plot two exposures' interaction effect
e.interaction.plot(model_1, dat, "X4_a.tocopherol", "X3_g.tocopherol")
e.interaction.plot(model_1, dat, "X4_a.tocopherol", "X10_2.3.4.6.7.8.hxcdf")
# exchange exposures' names
e.interaction.plot(model_1, dat, "X8_3.3.4.4.5.pncb", "X6_PCB156")
e.interaction.plot(model_1, dat, "X6_PCB156", "X8_3.3.4.4.5.pncb")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.