% \VignetteIndexEntry{Exposure to Dust - Generalized Additive Models} % \VignetteDepends{mgcv} %\VignetteEngine{knitr::knitr} %\VignetteEncoding{UTF-8} \documentclass[a4paper]{article} \title{Exposure to Dust - Generalized Additive Models} \begin{document} \maketitle <>= options(width=80) @ For GAMs the package "mgcv" is used. <>= library(mgcv) library(catdata) data(dust) @ The first model uses bivariate smoothing for the covariates "dust" and "years" from the "dust"--data. By the option "pers=TRUE" the bivariate effect can be plotted three--dimensional. <>= gamdust1 <- gam(bronch ~ s(dust,years), family=binomial, data=dust[(dust$dust<10) & (dust$smoke==1),]) plot(gamdust1, pers=TRUE) @ Now each covariate is fitted separately, afterwards both effects are plotted. <>= gamdust2<- gam(bronch ~ s(dust) + s(years), family=binomial, data=dust[(dust$dust<10) & (dust$smoke==1),]) @ <>= plot(gamdust2, select=1) @ <>= plot(gamdust2, select=2) @ \end{document}