R making predictions from lm
#using R
#Prepare simulation data:
a <- 1:5
b <- a^2
#predicting model
model <- lm(b~poly(a,2,raw=T))
predicted <- predict(model,data.frame(x=a),interval='confidence',level=0.99)
plot(a,b)
lines(a,predicted[,1],col="green",lwd=3)
#use the model coefficients to predict the newdata
summary(model)
x<-5:10 #newdata
y<-model$coefficients[1]+model$coefficients[2]*x+model$coefficients[3]*x^2
print(y)