Re: [R] about prediction with a factor

2011-02-10 Thread Dennis Murphy
Hi: There are a couple of things here. Firstly, if you intend to predict from a model in R, make sure your input to the model is a data frame. You can fit a model piecemeal with a set of vectors, but there's a distinct possibility you'll end up frustrated when trying to make predictions with new d

[R] about prediction with a factor

2011-02-10 Thread Zhao Jin
Hi, I don't know how to make prediction with a factor in the linear model. Say yd=c(1,2,3,4,5) > sl=c(2,3,4,5,6) > sex=c("male","male","female","female","male") > sex=factor(sex) > m=lm(sl~yd+sex+sex:yd) How to make a prediction with new data like yd=c(4,5,6,7,8) for male and female s