## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup, output=FALSE, message=FALSE, warning=FALSE------------------------ library(serosv) library(dplyr) library(magrittr) library(ggplot2) ## ----------------------------------------------------------------------------- # Prepare data tb_nl <- tb_nl_1966_1973 %>% mutate( survey_year = age + birthyr, survey_time = as.Date(paste0(survey_year, "-01-01")) ) %>% select(-birthyr) %>% filter(survey_year > 1966) %>% group_by(age, survey_year, survey_time) %>% summarize(pos = sum(pos), tot = sum(tot), .groups = "drop") head(tb_nl) ## ----------------------------------------------------------------------------- out_pava <- tb_nl %>% age_time_model( time_col = "survey_time", grouping_col = "survey_year", age_correct = F, monotonize_method = "pava" ) %>% suppressWarnings() out_scam <- tb_nl %>% age_time_model( time_col = "survey_time", grouping_col = "survey_year", age_correct = T, monotonize_method = "scam" ) %>% suppressWarnings() ## ----------------------------------------------------------------------------- out_pava out_scam ## ----warning=FALSE, message=FALSE--------------------------------------------- plot(out_pava, facet = TRUE, modtype = "non-monotonized") + ylim(c(0, 0.07)) plot(out_pava, facet = TRUE, modtype = "monotonized") + ylim(c(0, 0.07)) plot(out_pava, facet = FALSE, modtype = "monotonized") + ylim(c(0, 0.07)) ## ----warning=FALSE, message=FALSE--------------------------------------------- plot(out_scam, facet = TRUE, modtype = "non-monotonized") + ylim(c(0, 0.07)) plot(out_scam, facet = TRUE, modtype = "monotonized") + ylim(c(0, 0.07))