--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Such doubt and skepticism! ;)
You just need to use weight as an aesthetic:
qplot(hp, mpg, size=cyl, data=mtcars)+
stat_smooth(method="lm", aes(weight=cyl))
But I totally agree that when you're doing a more complicated model
it's much better to do it outside of ggplot so that you can check that
it's doing what you think it's doing.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
> I don't know if you can do weighted linear regression inside of ggplot2, butSuch doubt and skepticism! ;)
> I wouldn't expect it to be so. Perhaps someone else can show how it's done,
> if at all. Looking at the help page of stat_smooth(), there is no input
> argument for weights, so it would seem to be safer to fit a weighted model
> outside of ggplot2. Below is some code for weighted simple linear regression
> outside of ggplot2,where I created a data frame of predictions and then
> generated the equivalent of geom_smooth() manually.
You just need to use weight as an aesthetic:
stat_smooth(method="lm", aes(weight=cyl))
qplot(hp, mpg, size=cyl, data=mtcars)+