1
$\begingroup$

So this has been a headache for me. None of the resources I found could explain it in a manner I understand.

Having two sets of data:

x <- c(2, 4, 5, 6, 7, 8, 9, 9, 4, 5)
y <- c(0, 1, 0, 0, 0, 1, 1, 0, 1, 0)
df <- data.frame(x, y)

The y variable is binary and the x variable is continuous as you can see.

What I understand so far is that some machine learning models, like logistic regression, expect the log odds of the y variable to have a linear relationship with the y variable.

How would I make a plot that shows if they abide to this assumption or not and how would I read that plot? I prefer examples in R but any explanation you feel might contribute to my understanding is more than welcome.

$\endgroup$
  • $\begingroup$ You need a two-sample procedure with groups 0 and 1 determined by y and continuous variable in x. $\endgroup$ – BruceET May 25 '20 at 22:56
1
$\begingroup$

One way to look at the data:

x <- c(2, 4, 5, 6, 7, 8, 9, 9, 4, 5)
y <- c(0, 1, 0, 0, 0, 1, 1, 0, 1, 0)

stripchart(x ~ y, meth="stack", ylim=c(.5,2.5), pch=19)
  abline(h=1.5, col="green2")

enter image description here

From the stripcharts, we can see that the data values for the two groups are not much different. If integer values given in x are rounded continuous variables, then a 2-sample t-test would be appropriate, but with so much overlap between values for the two groups, I would not expect significance. Output from running this test in R shows a P-value greater than 5%, so the two sample means, 5.67 and 6.25, are not significantly different from each other.

t.test(x ~ y)

        Welch Two Sample t-test

data:  x by y
t = -0.359, df = 5.9956, p-value = 0.7319
alternative hypothesis: 
   true difference in means is not equal to 0
95 percent confidence interval:
 -4.560011  3.393344
sample estimates:
mean in group 0 mean in group 1 
       5.666667        6.250000 

Here are somewhat similar data for which there is a highly significant difference between groups.

stripchart(x1 ~ y, meth="stack", ylim=c(.5,2.5), pch=19)
  abline(h=1.5, col="green2")

enter image description here

t.test(x1 ~ y)

        Welch Two Sample t-test

data:  x1 by y
t = -5.2824, df = 5.9956, p-value = 0.001865
alternative hypothesis: 
   true difference in means is not equal to 0
95 percent confidence interval:
  -12.560011  -4.606656
sample estimates:
mean in group 0 mean in group 1 
       5.666667       14.250000 
$\endgroup$
  • $\begingroup$ You my friend are a hero. Could you by accident know anything about Wald's Test as well? I just learned this is a test that could be done to figure out if a independent variable can be used in a machine learning model to predict a dependent variable. $\endgroup$ – Ruud Verhoef May 26 '20 at 6:02
  • $\begingroup$ Sorry not sure about that reference. Wald was very prolific, so I'm not sure how to narrow it down by searching. Maybe include search word asymptotic. $\endgroup$ – BruceET May 26 '20 at 6:20
  • $\begingroup$ No problem. Just out of curiousity. Does using jitter/points plots difference from using boxplots to see if they split up nicely? As that is my simplistic interpretation of what you are doing. $\endgroup$ – Ruud Verhoef May 26 '20 at 8:03

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.