---
title: "GAM Example"
author: "Nov 26"
date: "26/11/2020"
output:
  html_document: default
  pdf_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(digits=4)
library(gam)
library(ISLR)
library(kableExtra)
```

```{r gam fits, echo=F}

gam1 <- gam(wage ~ s(year, 4) + s(age, 5) + education, data = Wage)
summary(gam1)

```
```{r gam plots}
plot(gam1, se=TRUE, col="blue")
```
```{r gam logistic}
gam.lr <- gam(I(wage > 250) ~ year + s(age, df=5) + education, family = binomial, data = Wage)
plot(gam.lr, se = T, col="red")
```