user54766
user54766

Reputation: 11

How to predict values of x given values of y (with previous x and y values included)

I am a beginner in R, and I want to predict orbit times of planetary objects based on their average distance from the Sun (in AU).

I thought using R would be great, so I have set

x<-c(0.387,0.723,1.000,1.524,5.203,9.537)
y<-c(87.969,224.701,365.256,686.980,4329.630,10751.805)

I typed model=lm(y~x) to fit a model onto it and then used predict.lm(model, newdata=new), where new=c(19.191,30.069,39.482).

I am returned with values but they are really off. I also tried taking the log of all the y values and tried that with the same process I just detailed. However, the values I am returned with are still off. I would appreciate any help to this problem or a resource that provides more help for R in this area. Thanks so much!

However, the given data value's plot was exponential, so if anyone could help to fit an exponential model instead of linear would be great.

Upvotes: 1

Views: 59

Answers (1)

Simon
Simon

Reputation: 5698

Your fit is off, because you try to fit a linear model to something that is not linear. Without being an astronomer, I think Kepler's Third Law is applicable. This formula, taken from Wikipedia, depicts the relationship between orbit times (in days) and distance (AU).

foo+bar

This could be rewritten as:

foo+bar

Which can be simplified to

foo+bar

Taking the log and fitting a linear model would work when the underlying process is exponential.

From here it seems that your model should be something like, although probably not exact, this: model=lm(y~x + I(X^(3/2))).

Upvotes: 1

Related Questions