pbreheny / visreg

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

Confidence interval tends to zero in quasi-parabolic contrast plots #36

Closed DanielReedOcean closed 6 years ago

DanielReedOcean commented 6 years ago

I have an issue when trying to make a contrast plot for GAMs that have a quasi-parabolic relationship. I've included a toy example below.

# Synthetic data
df <- data.frame(a = -10:10, b = jitter((-10:10)^2, amount = 10))

# Fit GAM
res <- gam(b ~ s(a), data = df)

# Make contrast figure
visreg(res, type = "contrast")

This code produces the plot below: rplot01

Notice that when a is zero, the confidence ribbon is zero.

pbreheny commented 6 years ago

I'm not sure I see the problem. A 'contrast' plot shows the estimated effect of changing 'a' away from a reference value (here, 0). The effect of changing a from 0 to 0 (i.e., not changing a) is indeed 0, and there's no uncertainty involved. All contrast plots for all kinds of models do exactly this.

DanielReedOcean commented 6 years ago

Hmm. I think I've misunderstood the purpose of the plot. Feel free to delete/close the issue.