# [R] Putting regression lines on SPLOM

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Sep 5 02:52:31 CEST 2003

```Thanks, Deepayan!
However, for me this has deepened the mystery (I don't really
understand in detail how lattice graphics works anyway!).

To clarify: The variables X,Y,Z,W in DF have some zero values,
and otherwise are positive. For U,V in X,Y,Z,W I plot log(1+V)
against log(1+U) for all the points. But I regress log(V) on
log(U) using only those points where both U and V are positive
(for these data the difference between log(U) and log(1+U) is
small when U>0, and has little effect on the plot; but I want
the regression to be as stated). Can this be incorporated into
the framework you suggest below?

Thanks!
Ted.

On 04-Sep-03 Deepayan Sarkar wrote:
> 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
>> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 05-Sep-03                                       Time: 01:52:31
------------------------------ XFMail ------------------------------

```

More information about the R-help mailing list