0
$\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
  • 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, 2016 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, 2016 at 17:59

2 Answers 2

3
$\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$
3
  • 2
    $\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, 2016 at 14:22
  • 2
    $\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, 2016 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, 2016 at 13:26
1
$\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$
7
  • 2
    $\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, 2016 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$ Aug 8, 2016 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, 2016 at 15:10
  • $\begingroup$ It is 'A' method but it is not correct to say it is the 'only' method. Using 'predict' as described by Qaswed would have to be simpler, especially when the model involved multiple co-efficients. $\endgroup$
    – dra_red
    Sep 20, 2019 at 13:24
  • $\begingroup$ @dra_red But this is exactly what predict does. $\endgroup$ Sep 20, 2019 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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