这个问题类似于这个问题:smooth with transformed y
事实上,它是相同的,只是解决方案不再有效。
我想要做的是绘制一个geom_smooth,它在公式的y边有log(y)。如果在formula参数中直接执行,则会给出一个奇怪的结果。因此,我会用我刚才提到的问题中所用的例子:
#This works:
myplot <- qplot(speed, dist, data=cars)
(myplot + geom_smooth(method="lm", formula=y~log(x)))
#does not work
(myplot + geom_smooth(method="lm", formula=log(y)~x))
#no longer works:
(myplot + geom_smooth(method = "glm", formula = y~x,
family = gaussian(link = 'log')))我想要的是这样一条线:
myplot + geom_line(aes(x=speed, y=exp(predict(lm(log(dist)~speed)))))发布于 2016-12-16 18:33:14
是的,你说得对,似乎必要的语法发生了一些变化:
(myplot + geom_smooth(method = "glm", formula = y~x,
method.args = list(family = gaussian(link = 'log'))))

https://stackoverflow.com/questions/41189823
复制相似问题