1
$\begingroup$

My data is binary with two linear independent variables. For both predictors, as they get bigger, there are more positive responses. I have plotted the data in a heatplot showing density of positive responses along the two variables. There are the most positive responses in the top right corner and negative responses in the bottom left, with a gradient change visible along both axes.

I would like to plot a line on the heatplot showing where a logistic regression model predicts that positive and negative responses are equally likely. (My model is of the form response~predictor1*predictor2+(1|participant).)

My question: How can I figure out the line based on this model at which the positive response rate is 0.5?

I tried using predict(), but that works the opposite way; I have to give it values for the factor rather than giving the response rate I want. I also tried using a function that I used before when I had only one predictor (function(x) ((log(x/(1-x)))-fixef(fit)[1])/fixef(fit)[2]), but I can only get single values out of that, not a line, and I can only get values for one predictor at a time.

I am using R.

Edit: I have added a contour plot over the heat plot (using geom_contour in ggplot2), which produces this:

Each cell represents the frequency of positive responses for a single stimulus.  I added the numbers for clarity.

I'd like to have a line that actually predicts the cutoff point in a fine-grained way; right now for the independent variables I have stimuli at points 40, 45, 50, etc. but I would like to see a line that predicts, e.g., that when x=32 and y=36 that's the threshold for 50% positive responses. It could be a curve or it could even be a straight line (whose slope might help visualise the relative contributions of the two factors), but I'm not looking for a pure description of the cells which are >50 vs <50, which is what I think this is doing, I'm looking for a way to plot the regression's predictions.

$\endgroup$
  • 1
    $\begingroup$ Just to clarify, you are using glm(), and you are interacting the two predictors on purpose? $\endgroup$ – robin.datadrivers Feb 19 '15 at 21:41
  • 1
    $\begingroup$ Although discussed in terms of R, I think this Q isn't about programming. $\endgroup$ – gung Feb 19 '15 at 21:59
  • $\begingroup$ Are you asking about a contour plot? $\endgroup$ – Glen_b Feb 19 '15 at 22:17
  • $\begingroup$ @robin.datadrivers I am using glmer() and I am interacting them on purpose although the effect of the interaction is marginal I think it makes sense to expect possible interaction here. $\endgroup$ – emily Feb 20 '15 at 2:48
  • $\begingroup$ @gung Sorry, does this mean I should post it elsewhere or something? $\endgroup$ – emily Feb 20 '15 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.