Concept

predict(): Predict New Data from the (Simple) Linear Model in R

  • predict() returns y-hat (estimate) based on your training model.
  • This method produces the confidence and prediction intervals for the prediction of YVAL given a value of the XVAL. In other words, for each training set, we have corresponding x and y values.
  • Now we have a new data set and we are passing a vector with one column from that new data and we want to predict the prediction/confidence intervals for that new data value based on the training data model.
predict(lm.fit, data.frame(XVAL=(c(new_data_row_value1, new_data_row_value2), interval = “”) #Example: predict(lm.fit, data.frame(XVAL=(c(5, 10,15)), interval = “prediction”) #Above, data.frame is included as an optional data frame that looks for variables to predict. Without it, fitted values are used. #interval = “confidence” , “none”, “prediction” are all options ```

0

1

Updated 2020-04-04

Tags

Data Science