[R] Use predict.lm

2006-05-02 Thread Jiang, Jincai \(Institutional Securities Management\)
Hi All, I created a two variable lm() model slm-lm(y[1:3000,8]~y[1:3000,12]+y[1:3000,15]) I made two predictions predict(slm,newdata=y[201:3200,]) predict(slm,newdata=y[601:3600,]) there is no error message for either of these. the results are identical, and identical to slm$fitted as

Re: [R] Use predict.lm

2006-05-02 Thread Gabor Grothendieck
Try this: # regression of Sepal.Length on cols 2 and 4 using first 100 rows iris.lm - lm(Sepal.Length ~ ., iris[,c(1,2,4)], subset = 1:100) # now do it with next 50 rows predict(update(iris.lm, subset = 101:150)) # double check - this gives same result as last line predict(lm(Sepal.Length ~ .,

Re: [R] Use predict.lm

2006-05-02 Thread Gabor Grothendieck
Sorry, I don't think that my earlier reply was what you wanted. Try this instead: # fit using first 100 points iris.lm - lm(Sepal.Length ~., iris[1:100,c(1,2,4)]) # predict using coefficients from above and variables from next 50 points predict(iris.lm, iris[101:150, c(1,2,4)]) On 5/2/06,