繁体   English   中英

如何在R中自定义效果图?

[英]How to customize effect plot in R?

我正在尝试一些效果图来显示回归结果。 我能够创建情节,但我提供的许多论据似乎并没有影响它的外观。 例如,此代码生成3个几乎相同外观的数字。 多线和地毯设置似乎不起作用。 我这样做了吗? 是否存在因文档中被视为“遗留参数”而导致的问题? 我在RStudio中使用R 3.5.1。 非常感谢!

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)))

您错误地将plot的参数放在effects 这有效:

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)

(注意m之后的paren,关闭参数列表以获得effect 。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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