pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

Conditioning reported for contrast plot #78

Closed jwbenning closed 4 years ago

jwbenning commented 4 years ago

Hi,

In creating a contrast plot for my glmer logistic regression, visreg reports the plot conditions: visreg(precip.2.glmer, "WinterSpringPrecip", type = "contrast", scale = "response")

Conditions used in construction of plot Easting: 362937 WinterSpringPrecip_PrevYr: 186.8 Year: 2017 Site: Black Gulch DamFrts: 63

But I thought contrast plots don't use conditioning? Is this just automatically printed, in case you specified type = "conditional"?

The plot looks like image

jwbenning commented 4 years ago

Also, is the interpretation of the Y axis here the change from probability = 0? i.e., is 0 the reference level here for the response?

EDIT: Actually I think I understand this now: it's change from the reference WinterSpringPrecip value (about 275, with response at ~0.5) -- so at WinterSpringPrecip = 100 (decrease of 175), the model predicts an increase in the response of ~ 0.2. Is that right?

pbreheny commented 4 years ago

First question: In general, yes: contrast plots don't use conditioning, and visreg does not print out any conditions. The exception to this is when the model contains an interaction. In this case, the relationship between x and y may be affected by other factors. To be on the safe side, visreg will print out these conditions if the model contains an interaction. If you don't want the conditions to be printed, you can always turn it off with print.cond=FALSE.

Second question: Hmm, interesting -- I did not anticipate people trying to use type="contrast" with scale="response". This is going to be problematic, and the resulting plot not likely to mean anything. I have now modified visreg so that any attempt to combine these options will trigger the following warning:

You are attempting to transform a contrast.  The resulting plot is not guaranteed to be meaningful.

Sorry to take so long to get back to you on this -- these issues were posted during finals last semester and I was too busy to respond at the time.