Skip to contents

This function uses maximum likelihood estimation to fit model parameters. The function uses the optim function from the stats package in R.

Usage

fit_model(time_series, age_dist, parmset, yinit, yinit.vector)

Arguments

time_series

An RSV hospitalization time series. Make sure this is rounded to whole numbers.

age_dist

The proportion of RSV hospitalizations in each age group (age groups include: <6 months,6-11 months,1-4 years,5-64 years, 65-74 years, 75+ years)

parmset

A list of fixed parameters (retrieved using the get_data() function)

yinit

A matrix of initial values for each model compartment(retrieved from get_data() function)

yinit.vector

A vector of initial values for each model compartment (retrieved from get_data() function)

Value

A list of fitted parameter values. Prints a plot showing the fitted model.

Examples

dat = get_data(state_or_county="state",state_abbr="CA",county_name=NULL)
#> Using the Vintage 2022 Population Estimates
#> Using the Vintage 2022 Population Estimates
parmset=dat[[1]]
yinit=dat[[2]]
yinit.vector=dat[[3]]

weekly_rsv = round(timeseries[which(timeseries$state=="California"),"value"])

fitLL = fit_model(time_series = weekly_rsv$value, age_dist = c(.19,.08,.23,.17,.10,.23),
parmset=parmset,yinit=yinit,yinit.vector=yinit.vector)