Learn R Programming

FluMoDL (version 0.0.3)

predict.FluMoDL: Predict method for FluMoDL objects

Description

Obtains predictions (predicted daily or weekly deaths) and optionally estimates standard errors of those predictions

Usage

# S3 method for FluMoDL
predict(object, temp = NULL, proxyH1 = NULL,
  proxyH3 = NULL, proxyB = NULL, proxyRSV = NULL, se.fit = FALSE,
  byWeek = FALSE, ...)

Arguments

object

A FluMoDL object

temp

A vector of daily mean temperatures. See 'Details'.

proxyH1

A vector of daily influenza A(H1N1)pdm09 incidence proxies. See 'Details'.

proxyH3

A vector of daily influenza A(H3N2) incidence proxies. See 'Details'.

proxyB

A vector of daily influenza B incidence proxies. See 'Details'.

proxyRSV

An vector of daily RSV incidence proxies (used only if the FluMoDL object includes an RSV term). See 'Details'.

se.fit

Logical switch indicating if standard errors are required. Requires byWeek=FALSE.

byWeek

If TRUE, aggregate fitted estimates by week. Has priority over argument se.fit. If both se.fit and byWeek are TRUE, se.fit is set to FALSE and a warning is returned.

...

Further arguments passed to or from other methods

Value

A vector of daily predicted deaths (corresponding to the rows in object$data). If byWeek=TRUE, the predictions are automatically aggregated by week (as per object$data$yearweek) and the vector contains the respective week (in YYYYWW format) as names.

If se.fit=TRUE, a list is returned with elements $fit and $se.fit containing the (daily) predicted deaths and their associated log standard errors.

Note that the first 30 elements (or first 5 elements if byWeek=TRUE) will be NA by default, as FluMoDL uses a maximum lag of 30 days.

Details

Arguments temp, proxyH1, proxyH3, proxyB and (if hasRSV(object) is TRUE) proxyRSV take a numeric vector as input, which is recycled to a length of nrow(object$data). Alternatively they can take NULL, in which case the respective column of object$data is used as input. Argument temp can also take the string "MMP", which is interpreted as the "Minimum Mortality Point", i.e. the temperature at which mortality is lowest (found in object$MMP).

In this way, the predict() method can be flexibly used to calculate the predicted "baseline" mortality (by setting temp="MMP" and all incidence proxies to zero), the model-predicted mortality for the actual input (by leaving all input arguments to their default NULL), or predicted mortalities for any combination of temperature and incidence proxy inputs.

Examples

Run this code
# NOT RUN {
data(greece) # Use example surveillance data from Greece
m <- with(greece, fitFluMoDL(deaths = daily$deaths,
    temp = daily$temp, dates = daily$date,
    proxyH1 = weekly$ILI * weekly$ppH1,
    proxyH3 = weekly$ILI * weekly$ppH3,
    proxyB = weekly$ILI * weekly$ppB,
    yearweek = weekly$yearweek))
m

# Calculate FluMoDL baseline
baseline <- predict(m, temp="MMP", proxyH1=0, proxyH3=0, proxyB=0, byWeek=TRUE)

# Calculate fitted predictions
fitted <- predict(m, byWeek=TRUE)

# }
# NOT RUN {
# Plot everything
plot(with(m$data, tapply(deaths, yearweek, sum)), type="l",
     xaxt="n", ylab="Weekly deaths", xlab="Time")
points(baseline, type="l", col="blue")
points(fitted, type="l", col="green")
legend("topleft", c("Actual", "Baseline", "Fitted"), lty="solid",
    col=c("black", "blue", "green"), bty="n")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab