[R] still problems with predict!

From: Anne <anne.piotet_at_urbanet.ch>
Date: Sat 17 Jul 2004 - 01:30:54 EST


Hi all,

I still have problems with the predict function by setting up the values on which I want to predict

ie:
original df: p1 (193 obs) variates y x1 x2

rm(list=ls())
x1<-rnorm(193)
x2<-runif(193,-5,5)
y<-rnorm(193)+x1+x2
p1<-as.data.frame(cbind(y,x1,x2))
p1

             y x1 x2
1 -0.6056448 -0.1113607 -0.5859728
2 -4.2841793 -1.0432688 -3.3116807
......

192 -1.3228239 1.0263013 -2.7801324
193 1.8736683 1.0480632 0.4746959

newdf<-data.frame(x1= seq(min( p1$x1),max( p1$x1),length=10),

                              x2=rep(median( p1$x2),10) )
pr<-predict(g<-lm(p1$y~p1$x1+p1$x2) ,newdf, se.fit = TRUE)

newdf

           x1 x2
1 -2.3844149 -0.2594991
2 -1.8388635 -0.2594991
...

9 1.9799963 -0.2594991
10 2.5255477 -0.2594991

pr$fit
1 -0.6766906
2 -4.4198864
.....

192 -1.6531906
193 1.6395442

so apparently the predict() function did not take up the new data.frame

I looked up with conflicts() to see if I had masked objects in the search path potentially causing this problem
but found none

Thanks and a good week end! (I for one need it) Anne



Anne Piotet
Tel: +41 79 359 83 32 (mobile)
Email: anne.piotet@m-td.com

M-TD Modelling and Technology Development PSE-C
CH-1015 Lausanne
Switzerland
Tel: +41 21 693 83 98
Fax: +41 21 646 41 33

R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 17 01:42:59 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:36:39 EST