I am trying to plot fitted lme values as a smooth line of a graph showing the exponential relationship between temperature and soil respiration.

In the plot, the x-axis has temperature, and the y-axis has soil respiration. When I try to add a line showing temperature versus the fitted values, it is jagged and not smooth.


Here is the code I used:

lme.1<-lme(fixed=LnFlux~Temp, random=~1|Plt, data=resp)
fit.1<-exp(fitted(lme.1))

plot(Flux$Temp, Flux$Flux, xlab="Temperature", ylab=expression("CO"[2]*"Flux"), xlim=c(-10, 25), ylim=c(0,250), pch=16)
ord1<-order(CFlux$Temp)
lines(CFlux$TempC[ord1], fit.1[ord1], lty=1, lwd=2)

This does not produce a straight line, but a jagged one that moves up and down between points.

If I use fitted values from a simple linear model (lm), I don't have this problem, and the line is smooth:

lm.1<-lm(LnFlux~Temp,  data=resp)
fit.2<-exp(fitted(lm.1))
plot(Flux$Temp, Flux$Flux, xlab="Temperature", ylab=expression("CO"[2]*"Flux"), xlim=c(-10, 25), ylim=c(0,250), pch=16)
ord2<-order(Flux$Temp)
lines(Flux$Temp[ord2], fit.2[ord2], lty=1, lwd=2)

The only difference I can find between the two is the structure of the fitted objects. The fit.1 object from lme is "atomic", and lacks individual data labels. Instead, the labels are: attr(*, "label")= chr "Fitted values". In contrast, the fit.2 object from the lm is "Named num", with: attr(*, "names")= chr [1:460] "1" "2" "3" "4".

Is this difference causing my problem with adding a smooth line to the graph? If so, is there any way I can change the structure of the lme fitted object to make it more amenable to adding a smooth line to a plot? Or is something else at work?

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to