Source:
vignettes/web/index.rmd
index.rmd
fit <- lm(Ozone ~ Solar.R + Wind + Temp, data=airquality)
and then you pass it to visreg
:
visreg(fit, "Wind")
A more complex example, which uses the gam()
function from mgcv:
library(mgcv)
# Loading required package: nlme
# This is mgcv 1.8-40. For overview type 'help("mgcv-package")'.
airquality$Heat <- cut(airquality$Temp, 3, labels=c("Cool", "Mild", "Hot"))
fit <- gam(Ozone ~ s(Wind, by=Heat, sp=0.1), data=airquality)
visreg(fit, "Wind", "Heat", gg=TRUE, ylab="Ozone")
# Loading required namespace: ggplot2