Skip to content
Prev 169218 / 398506 Next

Odp: Factor and Lm functions

Hi


r-help-bounces at r-project.org napsal dne 04.02.2009 12:33:57:
to
the
Factor changes D from numeric (1,2) to factor with levels 1 and 2. As a 
result from lm with such specified model you shall get one intercept and 2 
slopes one for level 1 and second for level 2 of D

see

x<-1:20
A<-sample(1:2, 20, replace=T)
y<-10+x*5*(A==1)+x*12*(A==2)+rnorm(20)
fit<-lm(y~x+x:factor(A))
plot(x,y)
summary(fit)
lines(x, 9.38+x*5.07268)
lines(x, 9.38+x*5.07268+x*6.98)

Regards
Petr
http://www.nabble.com/Factor-and-Lm-functions-
http://www.R-project.org/posting-guide.html