pbreheny / visreg

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

Wrong position of observations #101

Closed Marc-Girondot closed 2 years ago

Marc-Girondot commented 2 years ago

fit <- lm(Ozone ~ Solar.R + Wind + Temp, data=airquality) visreg(fit, xvar="Solar.R") points(x = airquality$Solar.R, y=airquality$Ozone, pch="+", col="red")

The grey points plot by visreg are not at the same place than red + Based on my understanding of the package function, they should be...

R 4.1.3 visreg 2.7.0

Thanks

pbreheny commented 2 years ago

The points are correct. visreg is plotting the partial residuals, not the observed outcome (i.e., the ozone levels after adjusting for wind and temperature, in your example above). If you want to know the relationship between x and y without adjusting for other variables, that's just simple linear regression. The point of visreg is to illustrate the multivariate model.

Marc-Girondot commented 2 years ago

Thanks for the precision. Marc