简体   繁体   中英

How to customize effect plot in R?

I'm trying to some effects plots to visualize regression results. I'm able to create the plot, but many of the arguments I'm supplying don't seem to affect its appearance. For example, this code produces 3 figures of nearly identical appearance. The multiline and rug settings don't seem to work. Am I doing this correctly? Is there an issue caused by the fact that these are considered "legacy arguments" in the documentation? I'm using R 3.5.1 in RStudio. Many thanks!

data("iris")
m = lm(Petal.Length ~ Petal.Width + Species + Species*Petal.Width, data=iris)
print(plot(effect("Petal.Width*Species", m, x.var="Petal.Width", z.var="Species", multiline=TRUE, rug=FALSE)))
print(plot(effect("Petal.Width*Species", m, x.var="Petal.Width", z.var="Species", multiline=FALSE, rug=FALSE)))
print(plot(effect("Petal.Width*Species", m, x.var="Petal.Width", z.var="Species", multiline=FALSE, rug=TRUE)))

#

You are incorrectly putting the arguments for plot within effects . This works:

m = lm(Petal.Length ~ Petal.Width + Species + Species*Petal.Width, data=iris)
plot(effect("Petal.Width*Species", m), x.var="Petal.Width", z.var="Species", multiline=TRUE, rug=FALSE)
plot(effect("Petal.Width*Species", m), x.var="Petal.Width", z.var="Species", multiline=FALSE, rug=FALSE)
plot(effect("Petal.Width*Species", m), x.var="Petal.Width", z.var="Species", multiline=FALSE, rug=TRUE)

(Notice the paren after m , closing off the argument list for effect .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM