The Wage
data set contains a number of other features not explored in this chapter, such as marital status (maritl
) and
job class (jobclass
).
In this exercise, we explore the relationships between these predictors and wage
,
and use non-linear fitting techniques in order to fit flexible models to the data.
Some of the exercises are not tested by Dodona (for example the plots), but it is still useful to try them.
Inspect summary statistics of the categorical variables maritl
and jobclass
.
Create a boxplot to check the average wage
for each of the categories.
Fit 3 GAM models and perform an ANOVA test to see which model fits best to the data:
fit1
, fit2
, fit3
) have a local regression term of year
with a span of 0.7,
a smoothing spline of age
with 5 degrees of freedom, and a linear function of education
.fit1
as it is.fit2
, add a linear function of jobclass
.fit3
, add both linear functions jobclass
and maritl
.anova.wage
. Inspect the results.
fit1
fit2
fit3
Assume that:
ISLR2
library has been loadedWage
dataset has been loaded and attachedgam
library has been loaded