[R] lattice add a fit

Bert Gunter gunter.berton at gene.com
Tue Oct 7 17:46:11 CEST 2014


Sorry,
you do **NOT** need to pass the covariates if the data argument to lm
is used. Or you can explicitly pass the covariates and subscript them
in your panel function.

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Tue, Oct 7, 2014 at 8:13 AM, Bond, Stephen <Stephen.Bond at cibc.com> wrote:
> Bert,
>
> Can you provide an example how to pass the conditioned data set?
>
> xyplot( x~y | z, data=mydata,
> panel=function(...){
> mod=lm(x~ y+w +q, data=??)
> panel.lines(fitted(mod))
>
> }
>
> If I use mydata in place of ?? I get a global fit, not a fit for each level of z, which is what I want.
>
> Stephen B
>
>
> -----Original Message-----
> From: Bert Gunter [mailto:gunter.berton at gene.com]
> Sent: Tuesday, October 07, 2014 9:30 AM
> To: Bond, Stephen
> Cc: r-help at R-project.org
> Subject: Re: [R] lattice add a fit
>
> Fit your model in the panel function using lm and plot the fits using ?panel.points, ?panel.lines, etc.
>
> -- Bert
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom."
> Clifford Stoll
>
>
>
>
> On Tue, Oct 7, 2014 at 6:01 AM, Bond, Stephen <Stephen.Bond at cibc.com> wrote:
>> What is the way to add an arbitrary fit from a model to a lattice conditioning plot ?
>>
>> For example
>> xyplot(v1 ~v2 | v3,data=mydata,
>>         panel=function(...){
>>             panel.xyplot(...)
>>             panel.loess(...,col.line="red")
>>         }
>> )
>> Will add a loess smoother. Instead, I want to put a fit from lm (but
>> not a simple straight line) and the fit has to be done for each panel separately, not one fit for the full data set, so sth like an lm equivalent of panel.locfit (there is no panel.lmfit) Thank you.
>>
>> Stephen B
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org 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.



More information about the R-help mailing list