% \VignetteIndexEntry{Number of Children - Partially Additive Model} % \VignetteDepends{mgcv} %\VignetteEngine{knitr::knitr} %\VignetteEncoding{UTF-8} \documentclass[a4paper]{article} \title{Number of Children - Partially Additive Model} \begin{document} \maketitle <>= options(width=80) @ For the following partially additive model the "children"--data from the package "catdata" are used. <>= library(catdata) data(children) @ Additive Models are fitted with the function "gam" from "mgcv". <>= library(mgcv) @ Here the model is fitted and the summary is printed. <>= gamchild <- gam(child ~ s(age) + s(dur) + as.factor(nation) + as.factor(god) + as.factor(univ), data=children, family=poisson(link=log)) summary(gamchild) @ Now the smooth effects can be plotted, the option "select" determines which effect is plotted. <>= par(cex=1.5) plot(gamchild, select=1, ylab="", xlab="Age") @ <>= par(cex=1.5) plot(gamchild, select=2, ylab="", xlab="Duration") @ \end{document}