## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup, output=FALSE, warning=FALSE, message=FALSE------------------------ library(serosv) library(dplyr) library(magrittr) ## ----------------------------------------------------------------------------- data <- parvob19_fi_1997_1998[order(parvob19_fi_1997_1998$age), ] ## ----------------------------------------------------------------------------- # Fit a Muench model muench <- polynomial_model(data, k = 1, status_col="seropositive") summary(muench$info) plot(muench) ## ----------------------------------------------------------------------------- # Provide a range of values for k best_param <- polynomial_model(data, k = 1:5, status_col = "seropositive") plot(best_param) # View the best model here which suggests k = 4 is the best parameter value best_param ## ----------------------------------------------------------------------------- hav <- hav_be_1993_1994 model <- fp_model(hav, p=c(1, 1.5), link="cloglog") model plot(model) ## ----warning=FALSE------------------------------------------------------------ model <- fp_model(hav, p=list( p_range=seq(-2,3,0.1), degree=2 ), monotonic=FALSE, link="cloglog") plot(model) # the best set of powers for this dataset is 1.5 and 1.6 model ## ----warning=FALSE------------------------------------------------------------ # ---- Best model with the monotonic constraint ----- model <- fp_model(hav, p=list( p_range=seq(-2,3,0.1), degree=2 ), monotonic=TRUE, link="cloglog") plot(model) # the best set of powers with the monotonic constraint is 0.5 and 1.1 model ## ----warning=FALSE------------------------------------------------------------ farrington_md <- farrington_model( rubella_uk_1986_1987, start=list(alpha=0.07,beta=0.1,gamma=0.03) ) farrington_md plot(farrington_md) ## ----------------------------------------------------------------------------- hcv <- hcv_be_2006[order(hcv_be_2006$dur), ] wb_md <- hcv %>% weibull_model(t_lab = "dur", status_col="seropositive") wb_md plot(wb_md) ## ----message=FALSE, output=FALSE, warning=FALSE------------------------------- df <- mumps_uk_1986_1987 model <- hierarchical_bayesian_model(df, type="far3") ## ----------------------------------------------------------------------------- model plot(model) ## ----message=FALSE, output=FALSE, warning=FALSE------------------------------- df <- rubella_uk_1986_1987 model <- hierarchical_bayesian_model(df, type="log_logistic") ## ----------------------------------------------------------------------------- model plot(model)