# Prediction Example -- source code file prediction.r # Create and print data frame points = data.frame(x=1:4, y=c(1, 3, 2, 4)) cat("points data frame\n") print(points) # Obtain regression model. model = lm(y ~ x, data=points) print(summary(model)) # Create new x-values to test model. newpoints = data.frame(x=c(0.5, 2.5, 4.25)) cat("newpoints data frame\n") print(points) # Obtain predicted values and prediction # interval for new data cat("Predicted values and prediction interval.\n") p = predict(model, newdata=newpoints, interval="prediction") print(p)