Model Predictions


predict (object, …)

a model object for which prediction is desired.

additional arguments affecting the predictions produced.









See Also


SafePrediction for prediction from (univariable) polynomial and spline fits.


  • predict
library(stats) # NOT RUN { require(utils) ## All the "predict" methods found ## NB most of the methods in the standard packages are hidden. ## Output will depend on what namespaces are (or have been) loaded. ## IGNORE_RDIFF_BEGIN for(fn in methods("predict")) try({ f <- eval(substitute(getAnywhere(fn)$objs[[1]], list(fn = fn))) cat(fn, ":\n\t", deparse(args(f)), "\n") }, silent = TRUE) ## IGNORE_RDIFF_END # }

Community examples at Apr 13, 2017 stats v3.3.3

``` #creates the x-axis (size) and y-axis (price) size <- c(2104, 1416, 1534, 852) price <- c(460, 232, 315, 178) data1 <- data.frame(size, price) plot(size, price, col = 2, pch = 16, xlab = "Size in feet²", ylab = "Price ($) in 1000", main = "Size versus Price") #makes a linear regression of the data lm_prices <- lm(price ~ size, data = data1) #uses the lm_prices' coef to plot the best line abline(coef(lm_prices), lwd = 1) lines(size[order(size)], price[order(price)], col = "blue") #predic the price for 1200 feet² size_1200 <- data.frame(size = 1200) predict(lm_prices, size_1200) ```