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 <bunnylover23 at optonline.net>
To: r-help at 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: