防止geom_smooth传递权重参数

时间:2015-03-09 08:27:28

标签: r ggplot2 statistics

我正在尝试将method传递给geom_smooth,我认为不会得到官方支持 - expectreg.ls来自expectreg。根据需要,expectreg返回的对象确实有predict方法。

但是,我认为geom_smooth尝试将weights参数传递给所提供的方法,并且由于expectile回归依赖于IRWLS类型算法,我认为提供外部weights论证没有意义,因此不是expectreg.ls的正式论证。在任何情况下,这都失败了:

Error in method(formula, data = data, weights = weight, ...) : 
  unused argument (weights = weight)

我还尝试修改expectreg.ls函数定义以添加虚拟weights参数,但然后ggplot2抱怨:

Error: geom_smooth requires the following missing aesthetics: y

此时,我已决定寻求帮助。是否有一种简单的方法可以让geom_smoothexpectreg.ls一起使用,而无需预先创建预测?


以下是一些测试解决方案的代码:

dfX = data.frame(x = rnorm(100), y = rnorm(100))
ggplot(dfX, aes(x, y)) +
  geom_smooth(method = "expectreg.ls", se = FALSE, aes(color = "Expectile Regression (alpha = 0.1)"), expectiles = 0.1) 

0 个答案:

没有答案