-1
$\begingroup$

There's not much more to ask than what I've written in the title.

Some of the values I want to predict are outside of the range used to build the regression model.

$\endgroup$
  • 2
    $\begingroup$ Can you please define "best"? It would be "best" to collect further data and thereby extent the range of training data so that you don't need to extrapolate. $\endgroup$ – Roland Aug 8 '16 at 9:18
  • $\begingroup$ Sorry about that. The best computational method to extrapolate values that are outside of the given range. $\endgroup$ – madsthaks Aug 8 '16 at 17:59
1
$\begingroup$

You can use the predict function. Try:

set.seed(123)

x <- 1:10
y <- -2 + 3 * x + rnorm(10)
our_data <- data.frame(y = y, x = x)
our_model <- lm(y ~ x, data = our_data)

predict(our_model, newdata =  data.frame(x = 20))
$\endgroup$
  • 1
    $\begingroup$ I believe the OP's concern is not with evaluation of the values but with the extrapolation involved in some cases. $\endgroup$ – whuber Aug 8 '16 at 14:22
  • 1
    $\begingroup$ I was under the impression that the predict function should not be used outside of the range used to build the regression model. $\endgroup$ – madsthaks Aug 8 '16 at 18:11
  • $\begingroup$ @user3552144 There is no such limitation in the predict.lm method. The method even provides the option of returning the prediction interval mentioned by whuber. Study help("predict.lm"). $\endgroup$ – Roland Aug 9 '16 at 13:26
0
$\begingroup$

Once your model and its parameters are fixed, there's only one way to do it: plug in the covariate values of the point you want to extrapolate at.

$\endgroup$
  • 1
    $\begingroup$ I would like to suggest that a good statistical answer would also provide information about how to assess the uncertainty in the extrapolation. That would address the implicit concern associated with extrapolation. $\endgroup$ – whuber Aug 8 '16 at 14:21
  • $\begingroup$ @whuber Fair enough request, but I'm not familiar with model-validation methods for extrapolation, only for a population that the training data is representative of. $\endgroup$ – Kodiologist Aug 8 '16 at 15:04
  • 1
    $\begingroup$ One aspect you could readily point to is the formula for a prediction interval (or the better-known formula for a confidence interval of the fit) and the fact that as the regressors move away from their centroid, either interval expands quadratically. That provides a quantitative way to assess how much extrapolation is occurring and what its effects are on the uncertainty in the prediction or fit. $\endgroup$ – whuber Aug 8 '16 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.