Again, you need to clarify what you mean by compare, but here's a better way to do predict from a linear model -- my first guess was simple interpolation (not very good):
m1 <- lm(y ~ x, data = data.frame(y = y1, x = x1)) m2 <- lm(y ~ x, data = data.frame(y = y2, x = x2)) predict(m1, newdata = data.frame(x = x)) predict(m2, newdata = data.frame(x = x)) Perhaps you want an ANOVA (?anova) test to compare the models: if you want to compare the predicted values at x directly, you could use interval="predict" for the different models and see if they overlap at a given confidence level. Michael PS -- Please do cc the list: I'm not a statistics expert by any means and I'd hate for what I say to go unreviewed by actual experts. On Sat, Mar 31, 2012 at 8:19 PM, AbouEl-Makarim Aboueissa <[email protected]> wrote: > I need to compare the value of y1-hat versus y2-hat corresponding to these > values of x<-c(0.10,0.20,2.0,15.0,35.0) > e.g. for x=0.10 compare y1-hat(x=0.10) versus y2-hat(x=0.10) and so on. > > thanks > abou > > >>>> "R. Michael Weylandt" <[email protected]> 3/31/2012 8:10 PM >>> > ? approxfun > > f1 <- approxfun(x1,y1) > f2 <- approxfun(x2,y2) > > f1(x) - f2(x) > > But I'm not sure what you mean be compare...do you have a particular > test in mind? > > Michael > > On Sat, Mar 31, 2012 at 8:04 PM, AbouEl-Makarim Aboueissa > <[email protected]> wrote: >> Dear All: >> >> I am trying to compare points on two regression lines given some specific >> values of X. I am not sure how to do it in R and/or in SAS. Can someone help >> me, and show me how to conduct such test in R. >> >> >> You can use the following data for both lines. >> >> ### data for line 1: >> ### ========= >> >> x1<-c(0.0,0.25,2.5,25.0,50.0) >> y1<-c(100.0,79.0,74.0,36.0,8.0) >> >> >> >> ### data for line 2: >> ### ========= >> >> x2<-c(0.0,0.25,2.5,25.0,50.0) >> y2<-c(100.0,79.0,55.0,18.0,2.0) >> >> >> ### these are the given values of X: >> ### =================== >> >> x<-c(0.10,0.20,2.0,15.0,35.0) >> >> >> thank you very much in advance >> abou >> >> >> >> >> >> >> >> >> ========================== >> AbouEl-Makarim Aboueissa, Ph.D. >> Associate Professor of Statistics >> Graduate Program Coordinator >> Department of Mathematics & Statistics >> University of Southern Maine >> 96 Falmouth Street >> P.O. Box 9300 >> Portland, ME 04104-9300 >> USA >> >> >> Tel: (207) 228-8389 >> Fax: (207) 780-5607 >> Email: [email protected] >> [email protected] >> >> Office: 301C Payson Smith >> >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> [email protected] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
