## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup, output=FALSE------------------------------------------------------ library(serosv) library(magrittr) ## ----------------------------------------------------------------------------- mump <- mumps_uk_1986_1987 ## ----------------------------------------------------------------------------- lp <- lp_model(mump, kern="tcub", nn = 0.5, deg=2) lp plot(lp) ## ----------------------------------------------------------------------------- # ----- Tune nearest neighbor (nn) parameter lp_model(mump, kern="tcub", nn = seq(0.2, 0.8, 0.1), deg=2) %>% plot() # ----- Tune bandwidth (h) parameter lp_model(mump, kern="tcub", h = seq(5,25), deg=2) %>% plot() ## ----fig.width=7, fig.height=3------------------------------------------------ plot_gcv( mump$age, mump$pos, mump$tot, nn_seq = seq(0.2, 0.8, by=0.1), h_seq = seq(5, 25, by=1) ) ## ----------------------------------------------------------------------------- lp_model(mump, kern="tcub", nn = 0.3, deg=2) %>% plot() lp_model(mump, kern="tcub", h = 14, deg=2) %>% plot()