On 1/17/2007 10:42 AM, Matt Sakals wrote:> I am trying to plot a non-linear trend line along with my data. I am
> sure the solution is simple; any help greatly appreciated.
>
> Recent and historic attempts:
> fit = nls((sd~a+b*exp(-c/time)+d*geology), start=list(a=1, b=1, c=10,
> d=-1), model=TRUE)
> plot(time, sd, col=3, main = "Regression", sub=formula(fit))
> lines(time, fitted.values(fit), lwd=2)
>
> #tt = seq(from=0, to=200, by=10)
> #lines(time, predict(fit, time=tt))
> #lines(time, predict(fit))
Your model has two independent variables, time and geology. You won't
get a simple trend line unless the value of geology is kept fixed. You
could do that with something like this code:
lines(time, predict(fit, newdata=data.frame(time=time, geology=0)))
Duncan Murdoch