I need to modify the lm (or eventually loess) function so I can use it in ggplot2's geom_smooth (or stat_smooth).
For example, this is how stat_smooth is used normally:
> qplot(data=diamonds, carat, price, facets=~clarity) + stat_smooth(method='lm')`
I would like to define a custom 'lm2' function to use as value for the 'method' para...
With the linear model function lm() polynomial formulas can contain a shortcut notation like this:
m <- lm(y ~ poly(x,3))
this is a shortcut that keeps the user from having to create x^2 and x^3 variables or typing them in the formula like I(x^2) + I(x^3). Is there comparable notation for the nonlinear function nls()?
...
Yesterday I worked up an example of the difference between Ordinary Least Squares (OLS) vs. Principal Components Analysis (PCA). For that illustration I wanted to show the errors minimized by OLS and PCA so I plotted the actuals, the predicted line and then I manually (with GIMP) drew in a drop line to illustrate a couple of the error te...