1
$\begingroup$

In my current project in R(language) I came along a problem which I cannot solve. I have a two column table with numbers representing measured rainfall in cm/m^2 and harvested kilograms of certain grain. For example: 6.4, 12.5 7.5, 15.4 ... 11.6, 45.0

How can I use R to find the approximate value of kilograms for a rainfall that is not in the table?

$\endgroup$
0
$\begingroup$

You are given 2-dimensional data - that is, your data has 2 parameters - and you want to find a way to relate both of them. Heuristically we believe that the kilograms of harvested crops are influenced by the rain, and not the other way around.

So we are looking for a magical function $f$, such that if you give it $r$, the measured rainfall, it will return the kilograms harvested. That is, we want to have an $f$ such that:

$$f(\text{rain measured}) = \text{kg harvested}$$

And more specifically it should make sense when compared to your table. The act of trying to fit functions against data is called regression. The most well-known regression is called linear regression and it the act of finding the best line that fits your values. There are other non-linear regression methods that fit polynomials or exponential functions to your data.

What you should try to do is find what type of regression would work best. Maybe plot your values on a graph and try to visualize if a line would be a good approximation. If not, try to guess the best shape that would fit the graph (maybe R does that for you? You will have to search for non-linear regression methods in R). There are also ways of making a non-linear regression become a linear one. See here for example. Then ask R to do the (non-)linear regression for you and you get yourself a function $f$ that should be decent at predicting the kg harvested provided you give it the measured rainfall.

PS You can start with trying linear-regression. Upon doing that, the software should give you a term, usually called $r$, that is a measurement of how good the approximation is. If either $r$ or $r^2$ is very close to $1$ then the approximation is a good one and you don't need to worry with finding other regression methods.

$\endgroup$
  • 1
    $\begingroup$ Thank you very much! Indeed linear regression fit to my data. $\endgroup$ – vendar Jan 20 '17 at 23:00
  • $\begingroup$ @vendar glad I could help! I hope you learned something new ;) $\endgroup$ – RGS Jan 20 '17 at 23:04

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.