3
$\begingroup$

There are a number of values for dependent variable (let's name it Y) and the same number of corresponding values for independent variable (let's name it X).

enter image description here How can i check if dependency Y(X) is linear? If my table would looks like (i.e. independent variable X will take only two values 0 or 1): enter image description here

Is it possible in that case that dependency Y(X) is linear? Why?

$\endgroup$
  • 1
    $\begingroup$ You should say what you mean by a linear relationship. Ordinarily, one says that ordinary (Pearson) correlation measures the linear component of association. So $|r|$ sufficiently near $1$ might be a criterion for linearity. // In your first dataset relationship seems linear, but not in the second. // I can't easily convert your 'pictures' to numbers, so I didn't actually find correlations for either. $\endgroup$ – BruceET Aug 29 '19 at 17:41
  • 2
    $\begingroup$ @Bruce Only some people make that claim about $|r|.$ I think it's overblown and misleading. A different interpretation of "linearity" is that alternative non-linear models aren't worth the additional complexity. There are two standard, textbook approaches to this: add a quadratic term or bin the independent variable(s). Run an ANOVA on the nested model. If it's not significant, conclude you haven't detected any nonlinearity. These are often called "goodness of fit" tests (which you surely know, but many of our visitors do not). $\endgroup$ – whuber Aug 29 '19 at 18:13
  • $\begingroup$ Thanks for link. $\endgroup$ – BruceET Aug 29 '19 at 18:36
  • $\begingroup$ @BruceET In the protocol i'm going to apply was mentioned: Note that if observations are, instead, linearly related to gradients, we have to use a Canonical Correlation Analysis (CANCOR) or Redundancy Analysis (RDA) instead of a Canonical Correspondence Analysis (CCA). So i'm not sure which definition author exactly mean. $\endgroup$ – Denis Aug 29 '19 at 18:52
  • $\begingroup$ @ whuber Thanks a lot. Could you provide some tutorial for these two methods (add a quadratic term and bin the independent variable) you mentioned please (if possible in r). I'm not a statistician and it's not easy to figure out that. What i already understand now from your post i have to make some linear models (perhaps with lm function) and then test them with ANOVA. But it's not clear which models i could make with one independent variable. Thank you again. $\endgroup$ – Denis Aug 29 '19 at 21:32
4
$\begingroup$

Sometimes a simple scatterplot alone is sufficient to make this determination. If the relationship is linear, I would expect a scatterplot of the data to show the data somewhat evenly scattered about a straight line - here, this is not the case, as the shape of the data from the first table has obvious curvature:

plot

As an simple example equation that would fit this curvature, here is a hyperbolic type equation "y = (a + (b * x)) / (c + x)" fitted to the data:

curved

and here is a straight line "y = a + (b * x)" fitted to the data:

straight

$\endgroup$
  • $\begingroup$ I'm wondering if it's possible in theory to have a linear dependency between X and Y if X take only two possible values 0 or 1? $\endgroup$ – Denis Aug 29 '19 at 22:00
  • 1
    $\begingroup$ In trivially simple cases yes, for example a data set with only two points such as [0, 5] and [1, 10]. A scatterplot of those two points will show that a straight line could trivially be made between them. However if you scatter plot the data in your second table, you should see that a straight line model is not going to fit that data at all - those data points do not lie on anything even close to a straight line. $\endgroup$ – James Phillips Aug 30 '19 at 2:00
  • 1
    $\begingroup$ Adding some more to James's answer: If your $x \in \{0,1\}$ and if you consider $y$ to be random (which is an automatic assumption when you talk about "fitting" a curve on x-y plot) then there is trivially a linear relationship between $E(y)$ and $x$. Think of this in terms of a box plot of $y$ w.r.t $x$. Box plot can also help you understand if the distribution of $y$ is different for $x=0,1$. $\endgroup$ – Dayne Aug 30 '19 at 3:57
  • $\begingroup$ Thanks! What is w.r.t? For only two points it's clear now. Thanks for the explanation. But what would be in case of multiple X and Y like in the 2-nd table (it's just a toy example). Is it possible? $\endgroup$ – Denis Aug 30 '19 at 8:44
  • 1
    $\begingroup$ wrt = With Respect To. that is, "y with respect to x". $\endgroup$ – James Phillips Aug 30 '19 at 10:40

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.