[R] Lattice plot with fitted curves

From: David Scott <d.scott_at_auckland.ac.nz>
Date: Fri 01 Sep 2006 - 16:43:48 GMT

I have some data which consists of time series for a number of sites. It appears that there is not much autocorrelation in the data and I have fitted a cubic for each site using lm. I would like to obtain a lattice plot with one panel for each site and showing the original data, and the fitted cubic.

The closest I have got to doing what I want is:

fit <- fitted(paraslm1)
temp <- cbind(paras, fit)
xyplot(Density ~ Year | LocCode, data = temp,

        panel = function(x, y, ...){
          panel.xyplot(x,y)
          panel.xyplot(x[LocCode],fit[LocCode],type="l")
        })

This doesn't give an error (most of my other attempts did), and draws the panels correctly with the original data, but doesn't draw the fitted lines.

paraslm1 is my fitted linear model with cubics for each location.

David Scott


David Scott	Visiting (July 06 to January 07)
 		Department of Probability and Statistics
 		The University of Sheffield
 		The Hicks Building
 		Hounsfield Road
 		Sheffield S3 7RH
 		United Kingdom
Phone:	+44 114 222 3908
Email:	d.scott@auckland.ac.nz

______________________________________________
R-help@stat.math.ethz.ch 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. Received on Sat Sep 02 03:12:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 07 Sep 2006 - 07:51:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.