Sorry Folks, I'm sure I could suss out the answer myself but I need it soon ... ! 1. Given a set of 4 variables X,Y,Z,W in a dataframe DF, I make a scatter-plot matrix using splom(DF). 2. I do all regressions of U on V using lm(U~V), where U and V are all 12 different ordered pairs from X,Y,Z,W. 3. Now I would like to superpose the regression lines from (2) onto the corresponding panels from (1). (By the way, the data used for the regressions are not quite the same as those used for the plots, since a few observations are omitted from the regressions but appear on the plots, so (1) and (2) really are separate operations). With thanks, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 04-Sep-03 Time: 17:47:39 ------------------------------ XFMail ------------------------------
You can't do it in that sequence, and whether you can do it at all depends on exactly what you mean when you say that the data used for the regressions are not the same as those used for the plots. The typical way would be to do splom(DF, panel = function(x, y, ...) { panel.xyplot(x, y, ...) # modify x and y as appropriate (?) # whether that can be done depends on whether # you have all the information you need # available inside the panel function fm <- lm(y ~ x) panel.abline(fm) }) Can't think of anything else (other than using a custom superpanel function). Deepayan On Thursday 04 September 2003 11:47 am, Ted Harding wrote:> Sorry Folks, > I'm sure I could suss out the answer myself but I need it > soon ... ! > > 1. Given a set of 4 variables X,Y,Z,W in a dataframe DF, I make > a scatter-plot matrix using splom(DF). > > 2. I do all regressions of U on V using lm(U~V), where U and V > are all 12 different ordered pairs from X,Y,Z,W. > > 3. Now I would like to superpose the regression lines from (2) > onto the corresponding panels from (1). > > (By the way, the data used for the regressions are not quite > the same as those used for the plots, since a few observations > are omitted from the regressions but appear on the plots, > so (1) and (2) really are separate operations). > > With thanks, > Ted. > > > -------------------------------------------------------------------- > E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> > Fax-to-email: +44 (0)870 167 1972 > Date: 04-Sep-03 Time: 17:47:39 > ------------------------------ XFMail ------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.math.ethz.ch/mailman/listinfo/r-help
Another query: I'm now trying to have the x- and y-axes all on the same scale (0:15) in every panel, whereas the default behaviour of splom is to scale them according to the ranges of the individual variables in each panel. So I tried (emulating the responses to my earlier query): splom(log(1+DF), panel = function(x, y, ... ) { panel.xyplot(x, y, xlim=c(0,15),ylim=c(0,15)) }) And it appears that the 'xlim' and 'ylim' specifications are ignored (i.e. the behaviour is exactly the same as splom(log(1+DF)). ?panel.xyplot refers you to ?xyplot for "further arguments", and ?xyplot certainly specifies the above form for specifying x- and y-limits. I think ... With thanks as always for any help, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 05-Sep-03 Time: 16:04:34 ------------------------------ XFMail ------------------------------
On 05-Sep-03 Deepayan Sarkar wrote:> > Oops, forgot the attachment. > > On Friday 05 September 2003 12:45 pm, Deepayan Sarkar wrote: >> The prepanel function returns separate limits for x and y axes. This >> does not translate to splom, since each limit is used on both the x >> and y axes. >> However, it is natural to add a new optional argument, which would be >> a function that would decide on the limits for each variable in the >> data frame, to be used as both x and y limits. This feature was >> missing till now, but I have added something for the next release >> (source() the attached file to use it), which will allow you to do: >> >> splom(log(1+DF), >> prepanel.limits = function(x) c(0, 15), >> panel = function(x, y, ... ) { >> panel.xyplot(x, y, ...) >> })Thanks again, Deepayan -- it works a treat! I guess it would be OK to insert the contents of your file "panel.limits.R" into the R code file of the "lattice" package, so that it is loaded every time? Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 05-Sep-03 Time: 19:57:54 ------------------------------ XFMail ------------------------------