[R] Help with lattice, regressions and respective lines
Jose Claudio Faria
joseclaudio.faria at terra.com.br
Sat Oct 15 01:34:13 CEST 2005
# 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
More information about the R-help
mailing list