Introduction to Machine Learning
Lecturer: Emi Tanaka
Department of Econometrics and Business Statistics
This dataset is available from http://research.stlouisfed.org/fred2.
yi=β0+β1xi1+β2xi12+⋯+β27xi127+ei
The model can be fitted using the loess
function where
In ggplot
, you can add the loess using geom_smooth
with method = loess
and method arguments passed as list:
span
changes the loess fitloess
worksmap_dfr(c(0, 2, 3, 8, 14, 48),
~ economics %>%
mutate(
nknot = .x,
nknot_label = paste(nknot, "knots") %>% fct_inorder()
)) %>%
ggplot(aes(date, uempmed, nknot = nknot)) +
geom_point() +
geom_smooth(
method = lm,
formula = y ~ splines::ns(x, df = nknot + 1),
se = FALSE,
colour = "orangered3"
) +
facet_wrap(~ nknot_label) +
ggtitle("Natural cubic splines")
ETC3250/5250 Week 2