Alireza, The "lm" function fits the linear regression (linear model), the "predict" function predicts new response values based on values of the predictor variables.
Try something like: > mydata <- data.frame( x=1:30, y=31:60+rnorm(30) ) > fit1 <- lm( y ~ x, data=mydata ) > summary(fit1) # optional > plot(fit1) # optional > newdata <- data.frame(x=3.5) > predict(fit1, newdata) Also you should reread section 11 of "An Introduction to R" to get more detail. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org] On Behalf Of Dr. Alireza Zolfaghari > Sent: Wednesday, November 12, 2008 1:57 PM > To: R-help > Subject: [R] Linear regression > > Hi List, > Does anybody know what function I need to use for a simple regression? > > Here is the data: I want to find the value for x1=3.5 > data<-data.frame(x=c(1:30),Value=c(31:60)) > x1<-3.5 > > Regards, > Alireza > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.