Skip to content
Prev 350685 / 398502 Next

predict function in regression analysis

Maybe this is what you wanted :

Data <- structure(list(y = c(4.5, 4.5, 4.7, 6.7, 6, 4.4, 4.1, 5.3, 4, 4.2, 4.1, 6.4, 5.5, 3.5, 4.6, 4.1, 4.6, 5, 6.2, 5.9, 3.9, 5.3, 6.9, 5.7), lot = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), duration = c(0L, 3L, 6L, 9L, 12L, 15L, 18L, 24L, 0L, 3L, 6L, 9L, 12L, 15L, 18L, 24L, 0L, 3L, 6L, 9L, 12L, 15L, 18L, 24L)), Names = c("y", "lot","duration"), class = "data.frame", row.names = c(NA, -24L))
Data$lot <- as.factor(Data$lot)
summary(Data)

(ANCOVA <- lm(y ~ lot + duration, data=Data))
summary(ANCOVA)
anova(ANCOVA)


#	diagram
color <- c("black", "red", "blue")
plot(y~duration, data=Data, pch=as.character(lot))

P <- predict(ANCOVA, int="c")
for(lev in levels(Data$lot)) {
index <- which(Data$lot==lev)
matlines(x=Data$duration[index], y=P[index,], col=color[as.integer(lev)])
}

Le 5 mai 2015 ? 22:41, Bert Gunter <gunter.berton at gene.com> a ?crit :
St?phane Adamowicz
Chercheur / Scientist
stephane.adamowicz at paca.inra.fr
Centre PACA - UR 1115 PSH
Tel. : +33 1 (0)4 32 72 24 35
Fax : +33 1 (0)4 32 72 24 32
228, route de l'A?rodrome
84 914 Avignon Cedex 9
France
www.inra.fr