Hello, The example below gives you some information about using predict(). This was originally used to predict NAs.
dat1<-data.frame(Year=1962:1986,Discharge=c(rnorm(15,25),rep(NA,5),1:5)) lm1<-lm(Discharge~Year,dat1) dat2<-data.frame(Year=dat1[,1]) dat1$fit<-predict(lm1,newdata=dat2) #The code below is to replace the NA values with predicted. #dat1<-within(dat1,{Dischargenew<-ifelse(is.na(Discharge)==T,fit,Discharge)}) #dat1new<-dat1[,c(1:2,4)] A.K. ----- Original Message ----- From: cm <bunnylove...@optonline.net> To: r-help@r-project.org Cc: Sent: Tuesday, July 24, 2012 2:20 PM Subject: [R] Linear Model Prediction I have data X and Y, and I want to predict what the very next point would be based off the model. This is what I have: >model=lm(x~y) I think I want to use the predict function, but I'm not exactly sure what to do. Thank you! -- View this message in context: http://r.789695.n4.nabble.com/Linear-Model-Prediction-tp4637644.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.