0

Here is some data and a logarithmic model:

df <- data.frame(
  x = 1:8,
  y = c(7.5,6,5.2,4.3,3.9,3.4,3.1,2.9)
)

model <- lm(y ~ log(x), data = df)

I am able to use this model to predict y for any given x e.g.

predict(model, newdata = data.frame(x = 10)) # 2.3

My question is, if I want to find y when x is known, can I do that? 'Reverse prediction' or what's the correct term?

e.g. If I want to know the value of x when the function output is 8, how would I do that?

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
Doug Fir
  • 1,218
  • 1
  • 13
  • 27

2 Answers2

1

I don't have enough reputation to comment, but I've heard it referred to as calibration or inverse regression. Hope that gives you something to start.

PRZ
  • 113
  • 4
1

In your specific case

Coefficients:
(Intercept)       log(x)  
      7.544       -2.268 

In original

$$y=7.544-2.268 \cdot \log(x)$$

therefore

$$(7.544 - y)/2.268 = \log(x)$$

or

$$\exp((7.544 - y)/2.268) = x$$

user2974951
  • 5,700
  • 2
  • 14
  • 27