[R] Help with lattice, regressions and respective lines
Petr Pikal
petr.pikal at precheza.cz
Mon Oct 17 10:26:14 CEST 2005
Hi
You are looking for functions
panel.*
especially panel.lmline, but I wondered if you can use linear for one
panel and quadratic for other panels. You could use a structure
provided in examples in xyplot help page to try to achieve what
you want. I do not have instant solution to your problem, maybe
somebody does :-)
HTH
Petr
On 14 Oct 2005 at 20:34, Jose Claudio Faria wrote:
Date sent: Fri, 14 Oct 2005 20:34:13 -0300
From: Jose Claudio Faria <joseclaudio.faria at terra.com.br>
Organization: UESC
To: "r-help at stat.math.ethz.ch" <r-help at stat.math.ethz.ch>
Subject: [R] Help with lattice, regressions and respective lines
Send reply to: joseclaudio.faria at terra.com.br
<mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe>
<mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>
> # Dear R list,
> #
> # I'm needing help with lattice, regression and respective lines. My
> # data is below:
>
> bra = gl(2, 24, label = c('c', 's'))
> em = rep(gl(3, 8, label = c('po', 'pov', 'ce')), 2)
> tem = rep(c(0, 0, 30, 30, 60, 60, 90, 90), 6)
> tem2 = tem^2
> r = rep(1:2, 24)
> y = c(40.58, 44.85, 32.55, 35.68, 64.86, 51.95, 42.52, 52.21,
> 40.58, 44.85, 33.46, 46.09, 12.75, 18.01, 16.82, 13.69,
> 40.58, 44.85, 34.45, 29.89, 34.91, 28.10, 27.52, 22.24,
> 48.68, 47.25, 45.58, 45.33, 41.03, 51.20, 45.85, 54.45,
> 48.68, 47.25, 19.88, 19.67, 16.20, 13.49, 13.75, 18.80,
> 48.68, 47.25, 42.19, 39.91, 34.69, 34.11, 32.74, 34.24)
>
> Df = data.frame(bra, em, tem, tem2, r, y)
>
> # Regressions
> attach(Df)
> Dfs1=subset(Df, (bra=='s' & em=='pov'), select=c(bra, em, tem,
> tem2, r, y)) Dfs1 rlin1=lm(y ~ tem + tem2, data=Dfs1)
> summary(rlin1)
>
> Dfs2=subset(Df, (bra=='s' & em=='po'), select=c(bra, em, tem, r,
> y)) Dfs2 rlin2=lm(y ~ tem, data=Dfs2) summary(rlin2)
>
> Dfs3=subset(Df, (bra=='s' & em=='ce'), select=c(bra, em, tem, tem2,
> r, y)) Dfs3 rlin3=lm(y ~ tem + tem2, data=Dfs3) summary(rlin3)
> detach(Df)
>
> # I would like to plot with lattice 'y ~ tem | em',
> # with the panels ('po', 'pov' and 'ce'),
> # and the its respective regressions lines:
> # a) linear for panel 'po' or better, without line;
> # b) quadratic for 'pov' and 'ce'
>
> # Is it possible? Could somebody hel me?
>
> # I'm trying:
> library(lattice)
> attach(Df)
> Dfs=subset(Df, bra=='s', select=c(bra, em, tem, y))
> Dfs
> xyplot(y ~ tem | em,
> data = Dfs, ylim=c(10, 60), xlim=c(-10, 110),
> ylab='y', xlab='Time, days',
> layout = c(3,1))
> detach(Df)
>
> TIA,
> --
> Jose Claudio Faria
> Brasil/Bahia/UESC/DCET
> Estatistica Experimental/Prof. Adjunto
> mails:
> joseclaudio.faria at terra.com.br
> jc_faria at uesc.br
> jc_faria at uol.com.br
> tel: 73-3634.2779
>
> ______________________________________________
> R-help at 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
Petr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list